Topic and replies count
-
Hello, How can I get the number of all topics and replies outside the bbPress forum?
-
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'] ); ?>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?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');Thanks a lot Robkk 🙂
Working great.Thanks for the function. Is there a way to output the amount of replies of a specific topic?
Thank you for your help.
Thanks for the function. Is there a way to output the amount of replies of a specific topic?
Thank you for your help.
@newguy Take a look at the
bbp_topic_reply_count()andbbp_get_topic_reply_count()functions.hello @robkk
can u help me, just displaying Registered Users on shortcode….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/
ooh oke, thanks @robin-w
- You must be logged in to reply to this topic.