Skip to content

Instantly share code, notes, and snippets.

@gvinter
Created May 21, 2012 13:02
Show Gist options
  • Save gvinter/2762209 to your computer and use it in GitHub Desktop.
Save gvinter/2762209 to your computer and use it in GitHub Desktop.
correct query for posts
<?php
$args = array( 'numberposts' => 3 );
$posts = get_posts( $args );
?>
<ul>
<?php foreach( $posts as $post ) : setup_postdata($post); ?>
<li class="grid_4 alpha omega">
<a href="<?php the_permalink(); ?>">
<?php if ( has_post_thumbnail('<thumnail-name>') ): ?>
<?php the_post_thumbnail('<thumnail-name>'); ?>
<?php else: ?>
<img src="http://placehold.it/300x145" alt="">
<?php endif; ?>
<div class="post-text">
<?php the_title(); ?>
<?php the_excerpt(); ?>
</div>
</a>
</li>
<?php endforeach; ?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment