Post Image

How to Display Related Posts by Same Author in WordPress

Users often want to read more and more articles from one author. The most of people subscribe on their favorite authors. But every time you finish reading the article, you need to return to the articles page to select a new.  Can you agree that this is not convenient? A more convenient way is to show the related posts by same author. Do you want to display related posts by same author in WordPress? In this article, we will show you how to manually display related posts by same author in WordPress. Related posts is very interesting tool, with it help you can suggestion more and more posts for user, and he will be never stop reading them :)

Manually Display Related Posts by Same Author in WordPress?

This method involves inserting code into a theme file. Knowledge of programming in this instance will be a plus. You will need to add the following code to your theme’s functions.php file or in a site-specific plugin.

function br_related_author_posts($content) {
 if (is_single) { 
    global $authordata, $post;     
    $content .= '<h4>Similar Posts by The Author:</h4> ';  
    $authors_posts = get_posts( array( 'author' => $authordata->ID, 'post__not_in' => array( $post->ID ), 'posts_per_page' => 5 ) );  
    $content .= '<ul>';
    foreach ( $authors_posts as $authors_post ) {
        $content .= '<li><a href="' . get_permalink( $authors_post->ID ) . '">' . apply_filters( 'the_title', $authors_post->post_title, $authors_post->ID ) . '</a></li>';
    }
    $content .= '</ul>';  
    return $content;
  } 
  else { 
    return $content; 
  }
} 
add_filter('the_content','wpb_related_author_posts');

You can now visit any single post on your website, and you’ll see related posts by the same author below the content.

It's all. If you want, you can add a template for related articles. For example: add an image and a message category and do it all as a grid view.

In conclusion

We hope this article helped you learn how to easily display related posts by same author in WordPress. Will be better, improve your site and yourself!