• I am trying to insert the archive.php code into a php enabled widget. I removed the header, sidebar, footer calls. The code works great, it shows everything correctly but the image. On the archive page it works fine, but in the widget, it shows the same image(thumbnail, featured image) for every post..

    archive code attached

    http://pastebin.com/4DWc0Pjh

    it has an if/else for how to display image, it displays the image from line 72 when used in the widget, I am guessing it has having trouble getting the link for the featured image or image from the post to use for the thumbnail.

    Why would it work when used in the archive.php, and not in the widget, everything works in the widget but the featured image. Could it need a function from another script?

    Thanks for any help -Pat

Viewing 1 replies (of 1 total)
  • As far as I know, bdw_get_images is not part of WordPress core? So without knowing what that function does it is difficult to say why it doesn’t work.
    You can get attached pictures using only wp core functions in a number of ways, for example:

    $args = array(
    	'post_type'      => 'attachment',
    	'post_parent'    => $post->ID,
    	'post_mime_type' => 'image'
    );
    $images = get_posts($args);
    echo '<img src="'.wp_get_attachment_url($images[0]->ID, 'thumbnail', false, false).'" />';

    I didn’t test this code, so tread carefully.

Viewing 1 replies (of 1 total)
  • The topic ‘archive.php hack’ is closed to new replies.