Forums

Join
bbPress Support ForumsTroubleshootingHow to get a total count of forums?

Info

How to get a total count of forums?

  1. How do I get a count of how many forums (and sub-forums) on the front page?

    "Viewing ### total forums"

  2. <p>Viewing <?php echo get_total_forums() ?> forums</p>

  3. Call to undefined function get_total_forums()

  4. That's a valid function in 1.0.2. What version are you using?

    http://trac.bbpress.org/browser/tags/1.0.2/bb-includes/functions.bb-statistics.php#L19

  5. Version 1.0.2

  6. <?php
    require_once( BB_PATH . BB_INC . 'functions.bb-statistics.php' );
    echo '<p>Viewing ', get_total_forums(), 'forums</p>';
    ?>
  7. Thanks! that works great. To go deeper into that code a code that does "forumS" for more than one and "forum" for just one?

  8. So the functions in bb-includes are not included on the front end or something? Why would you need to include them again? Are they just admin functions?

  9. To go deeper into that code a code that does "forumS" for more than one and "forum" for just one?

    $tf = get_total_forums();
    printf(__ngettext('Viewing %d forum', 'Viewing %d forums', $tf), $tf);

    functions.bb-statistics.php isn't automatically included. The statistics.php file (http://trac.bbpress.org/browser/tags/1.0.2/statistics.php#L5) does include that file as well.

  10. Thanks zaerl.

  11. You must log in to post.