How to Display Related Posts by Same Author in WordPress

Displaying related posts by same author is a pretty handy feature if you’re running a multi-author WordPress website. There are times when your visitors want to read contents from a specific author and it is possible to display related posts by same author in WordPress. Today, at DevotePress, we will be showing you two different methods to display related posts by same author in WordPress. So, without any further ado, let’s get right into the article.

Display Related Posts by Same Author in WordPress Using a Plugin

To display related posts by same author in WordPress via a WordPress plugin is quite easy and recommended for all the users, including the beginners.

In this method, the first thing you need to do is download and install the Similar Posts plugin from the WordPress plugin repository.

After activating the plugin, you need to visit Settings > Similar Posts page to customize the plugin your way.

similar posts

 

You will be able to see the General tab by default first. Here you can review the options and change them to match your requirements. You need to scroll down to the bottom and select “Yes” that’s next to the “Match the current post’s author” option. You can uncheck other matching options to make sure that the plugin only displays posts by author.

match the current post's author

Now, switch to the Placement tab and activate Output after post option. You can also edit the text in the Parameters to edit the output template.

output after posts

 

 

Click on the Save Settings button once you’re done with the plugin customization process. Visit any single post on your website and you’ll be able to see the related posts after the post content by the same author after.

display related posts by same author in WordPress

Now, let’s check out how we can display related posts by same author in WordPress manually.

Display Related Posts by Same Author in WordPress Manually

The second method is a little complicated than the first one as it requires you to add code to your WordPress theme file.

You need to open your currently activated theme, find the functions.php file, copy the below codes and paste it in your functions.php page. Remember that you must paste the code above the ?> sign.

 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 ) . '">' . apply_filters( 'the_title', $authors_post->post_title, $authors_post->ID ) . '</a></li>';
}
$output .= '</ul>';
return $output;
}

Now you need to open your single.php file and paste the following code inside the loop:

 <?php echo get_related_author_posts(); ?> 

The code will display 5 recent posts by the same author and it also makes sure that there are no other duplicates (the current posts will not be on the list). A simple trick that does the work without any hassle.

You can now visit the website and see the related posts by the same author.

Finally, we’ve come to an end of our article. We hope the above two methods helped you display related posts by same author in WordPress. If you’re a beginner or don’t want to mess around with coding, then we suggest you use the first method to display the related posts by the same author.

If you want to share anything with us, please leave your comments.

Leave a Reply

Your email address will not be published. Required fields are marked *