How to display thumbnails for related posts by author?
-
I try to get related posts by author using this 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' => 10 ) ); $output = '<div class="block">'; foreach ( $authors_posts as $authors_post ) { $output .= '<a href="' . get_permalink( $authors_post->ID ) . '">' . apply_filters( 'the_title', $authors_post->post_title, $authors_post->ID ) . '</a>'; } $output .= '</div>'; return $output; }
For output I use the following code inside the loop of my single.php file:
<?php echo get_related_author_posts(); ?>
Currently it displays only post titles as links.How should look this code in order to display thumbnails for this related posts by author function?
Thanks.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘How to display thumbnails for related posts by author?’ is closed to new replies.