Skip to content

Instantly share code, notes, and snippets.

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 josephdickson/bafa344ec06aff2ac95385c92e3fd511 to your computer and use it in GitHub Desktop.
Save josephdickson/bafa344ec06aff2ac95385c92e3fd511 to your computer and use it in GitHub Desktop.
<?php
if ( have_posts() ) :
while ( have_posts() ) : the_post();
echo '<article>';
echo '<a href="' . get_permalink() . '">';
the_title( '<h2 class="entry-title">','</h2>' );
if (has_post_thumbnail() ) {
// get thumbnail id for use later
$thumbnail_id = get_post_thumbnail_id();
echo '<figure>';
the_post_thumbnail('large');
if ( has_excerpt( $thumbnail_id ) ) {
// display figcaption only if there's a caption
echo '<figcaption>' . get_post( $thumbnail_id )->post_excerpt . '</figcaption>';
}
echo '</figure>';
}
echo '</a>';
the_excerpt();
echo '<article>';
endwhile;
else :
echo wpautop( 'No posts available' );
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment