Is it possible to display each users blog post count on a custom page?
For example, I use the following code to display a users total friend count on their profile page.
<a href="<?php echo bp_displayed_user_link().'friends/'; ?>"> <?php echo BP_Friends_Friendship::total_friend_count(bp_displayed_user_id()); ?> Friends</a>
Is there a php code to display a users total number of blog posts?
- Brajesh Singh on August 19, 2019 at 8:01 pm #24756
You can use
count_user_posts( $user_id, $post_type )
to get the count of user posts.
Please see this for example.
Thank you for leading me in the right direction. The following code worked for me.
<?php echo count_user_posts( $user_id = bp_displayed_user_id(), $post_type = 'post' ) ?>
When I arrive on a users profile, it now shows me how blog posts the users has created. Below is the code is its entirely.
<a href="<?php echo bp_displayed_user_link().'buddyblog/'; ?>"> <?php echo count_user_posts( $user_id = bp_displayed_user_id(), $post_type = 'post' ) ?> Blog</a>
This issue is resolved.
- Brajesh Singh on August 20, 2019 at 2:34 am #24780
Thank you for sharing.
I am glad it is resolved
The topic ‘ [Resolved] BuddyBlog – Display Blog Count – Custom Page’ is closed to new replies.