WordPress.org

Ready to get started?Download WordPress

Forums

Random Posts is Duplicating Thumbnails (2 posts)

  1. nickbudden
    Member
    Posted 3 years ago #

    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

  2. nickbudden
    Member
    Posted 3 years ago #

    Would this technique be incompatible with thumbnails?

Topic Closed

This topic has been closed to new replies.

About this Topic