Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End How to display post thumbnail? Reply To: How to display post thumbnail?

#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.