Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to get a total count of forums?

  • @gerikg

    Member

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

    “Viewing ### total forums”

Viewing 9 replies - 1 through 9 (of 9 total)
  • @zaerl

    Participant

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

    @gerikg

    Member

    Call to undefined function get_total_forums()

    @chrishajer

    Participant

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

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

    @gerikg

    Member

    Version 1.0.2

    @zaerl

    Participant
    <?php
    require_once( BB_PATH . BB_INC . 'functions.bb-statistics.php' );
    echo '<p>Viewing ', get_total_forums(), 'forums</p>';
    ?>

    @gerikg

    Member

    Thanks! that works great. To go deeper into that code a code that does “forumS” for more than one and “forum” for just one?

    @chrishajer

    Participant

    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?

    @zaerl

    Participant

    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 (https://trac.bbpress.org/browser/tags/1.0.2/statistics.php#L5) does include that file as well.

    @chrishajer

    Participant

    Thanks zaerl.

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