Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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
You can’t perform that action at this time.