Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Display Related Posts by Same Author in WordPress

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.

Displaying 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.

Similar posts 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.

Match 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.

Enable output

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.

Related posts by author displayed in WordPress

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.

Related posts by author displayed manually in WordPress

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.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit – a collection of WordPress related products and resources that every professional should have!

Reader Interactions

14 CommentsLeave a Reply

  1. 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

      Admin

    • You would want to reach out to the support for the ecommerce plugin you are using for how to set that up.

      Admin

    • 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

      Admin

  2. Hi there, the code works great but is there any way to include the post featured image thumb too? This would be so amazing!

  3. 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.

    // Related Author Posts
    
    function wpb_related_author_posts($content) {
    
        global $authordata, $post;
    
        $authors_posts = get_posts( array( 'author' => $authordata->ID, 'post__not_in' => array( $post->ID ), 'posts_per_page' => 5 ) );
    
    if ( is_single() && (count($authors_posts) > 1 ) ) {
    
        $content .= '<div class="similar_posts"><h3>Similar Posts by The Author:</h3> ';
    
        $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></div>';
    
        return $content;
        }
        else {
        return $content;
        }
    }
    
    add_filter('the_content','wpb_related_author_posts');
    
  4. 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?

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.