BuddyDev

Search

[Resolved] BuddyBlog – Display Blog Count – Custom Page

  • Participant
    Level: Enlightened
    Posts: 56
    John B on #24749

    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?

    Thx

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #24756

    Hi John,
    You can use

    
    count_user_posts( $user_id, $post_type )
    

    to get the count of user posts.

    Please see this for example.

    https://codex.wordpress.org/Function_Reference/count_user_posts

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 56
    John B on #24768

    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.

    Thx!!

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #24780

    Hi John,
    Thank you for sharing.

    I am glad it is resolved

    Regards
    Brajesh

The topic ‘ [Resolved] BuddyBlog – Display Blog Count – Custom Page’ is closed to new replies.

This topic is: resolved