Skip to:
Content
Pages
Categories
Search
Top
Bottom

Topic and replies count


  • snecz
    Participant

    @snecz

    Hello, How can I get the number of all topics and replies outside the bbPress forum?

Viewing 10 replies - 1 through 10 (of 10 total)

  • Robkk
    Moderator

    @robkk

    use the bbpress stats widget or shortcode [bbp-stats] in a page

    for just all topics it would placing these in a template.

    these come the template content-statistics.php which you could copy into child theme into a folder called bbpress and customize.

    <?php echo esc_html( $stats['topic_count'] ); ?>

    for just replies it would be

    <?php echo esc_html( $stats['reply_count'] ); ?>


    snecz
    Participant

    @snecz

    Thanks Robkk. [bbp-stats] is working. But I need topic count and replies count separately and in different places.
    So I’ve tried with <?php echo esc_html( $stats['topic_count'] ); ?> and <?php echo esc_html( $stats['reply_count'] ); ?> but this code doesn’t work on my home page.
    Why is that?


    Robkk
    Moderator

    @robkk

    @snecz

    i gave you two shortcodes for each instead

    place the two functions into your child themes functions.php or add the snippets to a functionality plugin.

    [bbp-topic-stats]

    function rk_bbp_topic_stats() {
        $stats = bbp_get_statistics();
        echo "<dl role='main'><dt>Topics</dt><dd><strong>";
        echo esc_html( $stats['topic_count'] );
        echo "</strong></dd></dl>";
    }
    
    add_shortcode('bbp-topic-stats', 'rk_bbp_topic_stats'); 

    [bbp-reply-stats]

    function rk_bbp_reply_stats() {
        $stats = bbp_get_statistics();
        echo "<dl role='main'><dt>Replies</dt><dd><strong>";
        echo esc_html( $stats['reply_count'] );
        echo "</strong></dd></dl>";
    }
    
    add_shortcode('bbp-reply-stats', 'rk_bbp_reply_stats');  

    snecz
    Participant

    @snecz

    Thanks a lot Robkk 🙂
    Working great.


    newguy
    Participant

    @dvrose

    Thanks for the function. Is there a way to output the amount of replies of a specific topic?

    Thank you for your help.


    newguy
    Participant

    @dvrose

    Thanks for the function. Is there a way to output the amount of replies of a specific topic?

    Thank you for your help.


    Brandon Allen
    Participant

    @thebrandonallen

    @newguy Take a look at the bbp_topic_reply_count() and bbp_get_topic_reply_count() functions.


    nobody
    Participant

    @iduy

    hello @robkk
    can u help me, just displaying Registered Users on shortcode….


    Robin W
    Moderator

    @robin-w

    bbpress just uses wordpress users, so this should get you what you want

    https://www.wpbeginner.com/wp-tutorials/how-to-show-total-number-of-registered-users-in-wordpress/


    nobody
    Participant

    @iduy

    ooh oke, thanks @robin-w

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.
Skip to toolbar