Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

Comments

  1. Bob the webbuilder says:

    Hi,

    Thanks for this article, works perfectly! I would only like to add a thumbnail as well and I can’t get it to work… its been asked before but since there’s no answer, I’ll try it one more time ;-)

    With kind regard,

    Bob the webbuilder

  2. Keshab says:

    How do i exclude or bypass certain author ?

  3. Kristin says:

    Hi … how can I make this list of links disappear altogether if the author has less than a set number of posts? For example, if I only want it to show if they have 3 or more posts?

    • WPBeginner Support says:

      You can try 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' => 5 ) );
      if (count($authors_posts) >= 3) { 
      
          $output = '<ul><li>Authors Posts</li>';
          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;
      
      } else { 
      
      
      return;
      }
      }
      
  4. hazel says:

    hey, thanks for this! is there a way to exclude posts by author ‘admin’
    I’ve tried editing the function plus i’ve also tried adding an if statement around the echo, to no avail :(

  5. ashkan says:

    hi
    how to limit charecter in title?

  6. Krystian says:

    Hi,

    How add pagination? Or limit post to 10?

    Best
    Krystian

  7. Wasim Shemna says:

    How can I display the related custom post of different authors? I do not want to show the related post values but I want to display their fields such as Logo, Title, Quantity and Price.

    But my algorithm would be to compare two products from woocommerce and show the similar products getting sold by different vendors. So it will be called as a related seller’s function.

    Is that possible? I need an automated display for list of seller and sellers list will be generated by the comparing the authors/sellers post title.

  8. Bambang says:

    Thanks a lot, it works nicely. Would it possible to display adjacent posts (last n posts and next n posts), instead of always recent posts of the author?

  9. Max says:

    Is there a way to paginate this?

  10. Todd Edelman says:

    Hi – I’ve implemented this function at http://bit.ly/1wpycm3 and tried to modify it by adding the thumbnail image as well as the post date and author to match the style that my theme’s widget uses. I cannot figure out what function to call to get the image, post date and author to display. Everything I call fails or causes a fatal crash. The code I’m working with is at http://codeshare.io/sA49o. Please help!

    • Carlos says:

      Did you ever figure out how to show a thumb, post date, and author name? Im trying to achieve this same layout but cant get it to work? Any help would be greatly appreciated.

  11. Mark Edward Ford says:

    I cannot seem to get this to work to show custom posts. I can see the created but no posts are displayed. It is a custom post called ai1ec.

    function get_related_author_posts() {

    global $authordata, $post;

    $authors_posts = get_posts( array( ‘author’ => $authordata->ID, ‘post_type’ => ‘ai1ec’, ‘post__not_in’ => array( $post->ID ), ‘posts_per_page’ => 5 ) );

    $output = ”;

    foreach ( $authors_posts as $authors_post ) {

    $output .= ‘ID ) . ‘”>’ . apply_filters( ‘the_title’, $authors_post->post_title, $authors_post->ID ) . ‘‘;

    }

    $output .= ”;

    return $output;

    }

  12. vvvvvvvvvvvvv says:

    how to add excerpt in the code?

  13. Ronnie Albert says:

    How would you add the date of post? Thanks

    • WPBeginner Support says:

      Try 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' => 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>'. the_date() .'</li>';
          }
          $output .= '</ul>';
      
          return $output;
      }
      
  14. Kushal Jayswal says:

    How can I see latest 5 post by same author in sidebar (through widget)? Any plugin available?

  15. Miguel Antekera says:

    This may work better without touch functions:

    $authordata->ID,
    ‘post_type’ => ‘recetas’,
    ‘showposts’ => ‘3’,
    ‘offset’ => ‘1’,
    ‘paged’ => get_query_var(‘paged’)
    )
    ?>

    • Anthony R Locke says:

      Please help me with this. Imagine me a complete idiot. How do I do this?
      1. Open Edit in Appearance.
      2. Click a file on the right side . . . single.php?
      3. Anywhere in the file paste this data and save it.
      4. The open a PAGE where I want the author’s name and posts to appear.
      5. So I do what?

      Sorry, I am not understanding how to do this?
      $authordata->ID,
      ‘post_type’ => ‘recetas’,
      ‘showposts’ => ’3′,
      ‘offset’ => ’1′,
      ‘paged’ => get_query_var(‘paged’)
      )
      ?>

      • WPBeginner Support says:

        Paste the first code in your theme’s functions.php file and the second line of code in your theme’s single.php file right below the_content()

  16. Lance says:

    Awesome. worked a treat. Love it.

  17. Michael says:

    Is there a way to make it display different posts counts by author ID?

  18. savarez says:

    I´ve tried to use these also in Page, but there it doesn´t work. Is there any easy fix for that use?

  19. CricShowers says:

    Hi, this was a noce post and I have tried using this in one of my site. I was just wondering how to add thumbnails to the posts. Any help appreciated,

  20. Wadams says:

    Will this gather all posts published across a multisite network regardless of which individual blog a post appears?

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.