WordPress.org

Support

Support » Themes and Templates » Random Posts is Duplicating Thumbnails

Random Posts is Duplicating Thumbnails

  • Hi,

    I’m trying to hard code a random posts area in my sidebar. I got this from the codex:

    <li>
    		    <h2>random posts</h2>
    			<ul>
    			<?php $rand_posts = get_posts('numberposts=4&category_name=blog&orderby=rand');
    				foreach( $rand_posts as $post ) : ?>
    
    			<li><div class="sidebar-post" id="post-<?php the_ID(); ?>">
    
    			<?php if ( has_post_thumbnail() ) { } else { } ?>
    			<?php the_post_thumbnail(); ?>
    
    			<div class="blog-post-text">
    			<h3><?php the_title(); ?></h3>
    			<?php the_excerpt(); ?>
    			<p><a href="<?php the_title_attribute(); ?>">view now...</a></p>
    			</div></li>
    
    			</div>
    
    				<?php endforeach; ?>
    				</ul>
    
    		</li>

    The problem is that each post is picking up the same thumbnail (the first post’s thumbnail). You can see this at http://pixelbang.com/travel in the bottom of the sidebar.

    Would anybody be able to help me out?

    Thanks,

    Nick

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Random Posts is Duplicating Thumbnails’ is closed to new replies.