Skip to content

Instantly share code, notes, and snippets.

@jdcauley
Created July 8, 2014 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdcauley/88f6524efef4e4451e5b to your computer and use it in GitHub Desktop.
Save jdcauley/88f6524efef4e4451e5b to your computer and use it in GitHub Desktop.
Recent Post Loop
<?php $the_query = new WP_Query('showposts=3'); ?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<div class="recent-post-wrapper">
<?php if (has_post_thumbnail()): ?>
<div class="recent-post-img">
<?php the_post_thumbnail('', array('class' => 'img-responsive')); ?>
</div>
<div class="recent-post-copy">
<h4><?php the_title(); ?></h4>
<p><?php echo excerpt(15); ?></p>
</div>
<a class="btn btn-secondary btn-xs" href="<?php the_permalink(); ?>">Read More</a>
<?php else: ?>
<h4><?php the_title(); ?></h4>
<p><?php echo excerpt(15); ?></p>
<a class="btn btn-default btn-xs" href="<?php the_permalink(); ?>">Read More</a>
<?php endif; ?>
</div>
<?php wp_reset_postdata(); ?>
<?php endwhile; ?>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment