Skip to:

conditionals with is_forum()

  • Is there a way to add a parameter to the function to check if the user is viewing a specific forum (by forum name or ID). It seems like it would be included I just can’t find a full explanation of the function and figured someone here might know.

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

  • _ck_


    To learn how bbPress works, I would suggest browsing the source of the top level files in the bbPress root.

    is_forum simply checks the url and does not know which forum it is in

    but it can be used before repermalink happens (similar to wordpress)

    to get the current forum, in theory you should be able to

    global $forum_id;

    And then the $forum_id is the current forum number. You can then use the api to get the forum name, etc. if desired.

    This may not work in all cases as bbPress has some nasty code in some places that even in 1.0 still does not reset the counter after loops. For example a forum page that has some sub-forums, the $forum_id might very well be the last sub-forum displayed (if the bug has not been fixed yet).

    You also cannot fetch $forum_id before repermalink happens which is after bb_init is triggered. Shouldn’t be a problem unless you are trying to execute code while a plugin is loading vs. after init

    ps. is_forum is deprecated in 1.0, use bb_is_forum

    I tried inserting

    <?php global $forum_id; echo $forum_id; ?>

    just to test if I could grab the value and I could not. I tried it in a few places with no luck. What am I doing wrong?

    Also thanks for all the plugins. I’ve got like a dozen of them running on my install.

    d’oh! this works:

    <?php global $topic; echo "$topic->forum_id"; ?>

    should’ve mentioned I was on a topic page



    thanks guys, just what I needed. I’m creating RSS-driven email lists through mailchimp, so those unfamiliar with RSS can subscribe easily to each forum topic they choose.

    Then using CK’s code to get the forum ID, showing the proper email signup form for each forum page that corresponds with that forums’ RSS-driven campaign on mailchimp.

    <?php global $topic;
    $current_topic = $topic->forum_id;
    echo $current_topic;
    if ($current_topic==2) {

    Maybe someone else will find useful? It’s a bit labor intensive to set up, but I couldn’t figure out a better way to let people subscribe to individual forums.

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