Skip to:
Content
Pages
Categories
Search
Top
Bottom

Add “forum id” number to the in forum and topic


  • leev
    Participant

    @leev18

    If you inspect the body tag of this website in this/the “request and feedback” forum page, you can see that the id number for the forum is 652. If you go to any topic in this “request and feedback” forum and inspect the code in there, you can see that there is a number, 652, identifying that the topic is posted in the “request and feedback” forum.

    Basically, I want to add the forum id number class to the <body> depending on the forum, or the topic that is posted in that forum.

    Example, <body class=”[forum_id_number]”>.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi leev18,

    The function bbp_get_forum_id() should return to you the forum id.

    Pascal.


    Robkk
    Moderator

    @robkk

    Are you talking about where it says something similar to this in the body class. Most themes add this not really bbPress itself. If you are missing this <?php body_class(); ?> in your theme you not be able to see the post id.

    postid-652

    Or for the topic list of the forum where it shows this.

    bbp-forum-652

    If you have been heavily editing bbPress templates in your child theme you may not have this in correctly in loop-single-forum.

    <ul id="bbp-forum-<?php bbp_forum_id(); ?>" <?php bbp_forum_class(); ?>>


    leev
    Participant

    @leev18

    <?php bbp_forum_id(); ?> is what I’m looking for.

    I added <?php bbp_forum_id(); ?> to the <body <?php body_class();?>> in the the head.php of my wp theme.

    So, now, I got this <body <?php body_class();?> <?php if(is_single()) : ?>id=”parent-forum-id-<?php bbp_forum_id() ?><?php endif; ?>>

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