Home › Forums › Back End › How to display post thumbnail? › Reply To: How to display post thumbnail?
January 13, 2016 at 10:47 am
#236754
Senff
Participant
@Tiaan79 Instead of using ULs and LIs, use different markup.
In my code above, the UL and /UL are wrapped around all the posts, and the LI and /LI around every individual post. You can easily replace that with different markup, for example:
<?php
$args = array('showposts' => 5);
$the_query = new WP_Query( $args );
if( $the_query->have_posts() ):
echo '<table>';
while ( $the_query->have_posts()) : $the_query->the_post();
echo '<tr><td><a href="'.get_the_permalink().'">'.get_the_post_thumbnail().' '.get_the_title().'</tr></td>';
endwhile;
echo '</table>';
endif;
wp_reset_query();
?>
This will put each post entry on its own line. If you want to have 2 or more posts per line/row, you’re going to have to use counters of some sort.