How to display recent post thumbnail images
-
Hi all,
I use a function that displays the specific author’s (for a multiple author blog) 5 recent posts – which works fine. However, I would like to also display the featured images of each one of those posts along with the title, but right now it displays the same 5 images of the current page.
I am using get_the_post_thumbnail to call the image, but can’t figure out how to specify the code. Here is the code:
function get_related_author_posts() { global $authordata, $post; $authors_posts = get_posts( array( 'author' => $authordata->ID, 'post__not_in' => array( $post->ID ), 'posts_per_page' => 5 ) ); $output = '<ul>'; foreach ( $authors_posts as $authors_post ) { $output .= '<li><a href="' . get_permalink( $authors_post->ID ) . '">' . get_the_post_thumbnail( $post->ID, array(100,100) ) . apply_filters( 'the_title', $authors_post->post_title, $authors_post->ID ) . '</a></li>'; } $output .= '</ul>'; return $output; }
Here is a link to what it currently looks like (see the sidebar)
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to display recent post thumbnail images’ is closed to new replies.