Display Author Posts in Buddypress User Profile

Here’s a short Buddypress code snippet which will implement author made posts to their user Buddypress profiles. First it introduces a new profile tab, in this case named My Posts, followed by a simple query to get the author’s posts.

You can easily structure the posts by linking to your specific template part in get_template_part( 'member-posts' ); . For instance, linking archive.php could save time over having to create a new template part.

Finally, if the user isn’t the author of any posts, a message will be displayed in the Buddypress My Post profile tab.

Copy paste the following code to your function.php or bp-custom.php.



  1. Thank you for this code snippet. The snippet works to show the recent 5 posts on the profile. But does not include the pagination to next page that includes post 6 to 10 and so on. Can you please guide on how to add pagination to this code?

    1. Hi Nitin, there are some pretty good posts out there on doing custom wordpress loop paginations. Check out http://callmenick.com/post/custom-wordpress-loop-with-pagination or you can dig through https://codex.wordpress.org/Pagination for some examples.

      As for including more posts on the first page, you can quickly change that by adding, for instance, showposts=12 in the wp_query. So the code would look like this:

      $query = new WP_Query( ‘showposts=12&author=’ . $user_id );

      The number 12 is, of course, changeble to however many posts you want on the first page. Let me know what you come up with or if you need more help.

  2. This is great! Any idea why it wouldn’t work for all members with posts? It is only showing for the admin. Other members don’t even show the message that the author doesn’t have any posts.


    1. Hi Justin, it sounds like something is obstructing the code from showing, maybe the theme, other custom code or a plugin.

      Did you try switching to a standard theme and deactivating your plugins one by one to see if anything is changing?

  3. Thank you for this. Works perfectly for me. Just added this code below the loop to link to that author’s archive.
    echo '<a href="' . get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ) .' " rel="nofollow"> View All Posts by This Author</a>';

      1. Hi Azik, you could change the post_type by adding an array to the query. Here’s an example with multiple post_types.

        so the full new code would be the following:

Leave a Reply to Azik Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.