Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jonathanhudak/5474525 to your computer and use it in GitHub Desktop.
Save jonathanhudak/5474525 to your computer and use it in GitHub Desktop.
A snippet to list recent posts with their post thumbnail on the Single.php template, which excludes the current Single Post.
<div class="recent-post-list">
<?php
$the_query = new WP_Query(array('showposts' => 5, 'orderby' => 'post_date', 'order' => 'desc', 'offset' => 1, 'post__not_in' => array( $post->ID )));
while ($the_query->have_posts()) : $the_query->the_post(); ?>
<div class="recent-post">
<a title="<?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark">
<?php the_post_thumbnail(array(50,50, true), array ('')); ?>
<h3><?php the_title(); ?></h3>
</a>
<div class="clear"></div>
</div>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment