Do you want to display related posts by same author in WordPress? Normally, you can use any related posts plugin to show similar articles on your website. However if you run a multi-author WordPress website, then your users may want to read other content from the same author. In this article, we will show you how to display related posts by same author in WordPress.
Method 1: Display Related Posts by Author in WordPress Using Plugin
This method is easier and is recommended for all users.
First thing you need to do is install and activate the Similar Posts plugin. For more details, see our step by step guide on how to install a WordPress plugin.
Upon activation, you need to visit Settings » Similar Posts page to configure plugin settings.
The settings page is divided into different tabs, and you will land on the General tab by default. You can review the options and change them to match your requirements.
On this page, you need to scroll down to the bottom and select ‘Yes’ next to ‘Match the current post’s author’ option. You can uncheck other matching options to make sure that the plugin only fetches posts by author.
Next, you need to switch to the ‘Placement’ tab and activate ‘Output after post’ option. You can also edit output template by editing the text in the ‘Parameters’ box.
Don’t forget to click on the ‘Save Settings’ button to store your changes.
You can now visit any single post on your website, and you’ll see related posts by the same author after the post content.
Method 2: Manually Display Related Posts by Same Author in WordPress
This method requires you to add code to your WordPress theme files. If you haven’t done this before, then check out our guide on how to copy and paste code in WordPress.
You will need to add the following code to your theme’s functions.php file or in a site-specific plugin.
function wpb_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.
We hope this article helped you learn how to easily display related posts by same author in WordPress. You may also want to see our ultimate list of the most wanted WordPress tips, tricks, and hacks for beginners.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
Apologies for opening this up again after all these years, but could you tell me how to place this related posts content somewhere other than “after entry content”? E.g. If I wanted it to appear after the author info or after the comments section? Thank you!
If you wanted to customize the specific location it appears then you would need to change ‘the_content’ to where you would like to add the content
How can Display Related Product by the Same Author in Wp sidebar
You would want to reach out to the support for the ecommerce plugin you are using for how to set that up.
Great, Thank you for your article!
is it possible to get same data from CPT?
To do that you would want to add to the array of arguments to include the post type. For line 8 you would want it to be:
$authors_posts = get_posts( array( ‘post_type’ => ‘book’, ‘author’ => $authordata->ID, ‘post__not_in’ => array( $post->ID ), ‘posts_per_page’ => 5 ) );
Replace book with your custom post type
Great! thank you!
You’re welcome
Hi there, the code works great but is there any way to include the post featured image thumb too? This would be so amazing!
Hi Ryan,
Yes, you can add
the_post_thumbnail();
to display featured image.Great thanks! Sorry I am not much of PHP developer. Where would it go into the code to have it display? Thanks so much!
Yes that works. Thanks!
And I found and fixed another issue… If the author only has one post the Related Posts area shows but there is no information in it. To solve this, I did the following. And I also added a div around the content in order to style the area.
I’m testing the above functions.php code on a development site. The related posts are showing up on the bottom of pages also, like the contact us page. As you are using is_single this shouldn’t be happening. Do you have any insight on why this is happening?
Hi Trishah,
Thanks for reporting this. There was a tiny error in the code that caused this. We have fixed the error, you can now try the new code snippet.