Support » Fixing WordPress » Post Thumbnails Are Repeating — Wuh huh?!

  • Resolved mmachine

    (@mmachine)


    I’m having issues displaying post_thumbnails with a get_posts function. What’s happening is that say I’ll pull 10 posts, all which render appropriately in my HTML (titles, excerpts, etc. etc.) EXCEPT in the case of the post_thumbnail call — it renders the post thumbnail of only the first returned post, but does it for each post return entry. So, I have 10 different post listings with their appropriate titles, excerpts, permalinks, etc, but all of them share the post thumbnail of the first returned post.

    Here’s an example of some of the problematic code:

    <?php
    	global $post;
    	$myposts = get_posts('category_name=Video&orderby=date&numberposts=3');
    	foreach($myposts as $post) :
    ?>
    	<div style="float:left; width:98%; height:160px;">
    		<div style="float:left; margin:0px 10px 0px 0px;"><?php the_post_thumbnail('medium'); ?></div>
    		<h3><?php the_title(); ?></h3>
    		<p><?php the_excerpt(); ?>
    		<a href="<?php the_permalink(); ?>">Click to Watch!</a>
    	</div>
    <?php endforeach; ?>

    Any thoughts? A bug/incompatibility to using get_posts() in conjunction with the the_post_thumbnail()? Would I be better of using a query_posts() call instead?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Post Thumbnails Are Repeating — Wuh huh?!’ is closed to new replies.