Skip to:
Content
Pages
Categories
Search
Top
Bottom

subforum parent name


  • momomoko
    Participant

    @momomoko

    hi guys,

    i would like to know how to add parent forum title for each subforum on the single forum page . something like “if bbp-forum-title has parent then parent name : bbp-forum-title” .

    Thank you for your help

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

  • Robin W
    Moderator

    @robin-w

    untested but try

    $forum = bbp_forum_id() ;
    $parent = wp_get_post_parent_id($forum) ;
    if (!empty($parent)) {
     echo esc_html( get_the_title($parent) ) ;
    }

    momomoko
    Participant

    @momomoko

    Thank you dear for your quick reply ; i copy/past the loop single forum file into my child theme root (what i did is the good way to do that ?) , then i added your script like this :

    <a class="bbp-forum-title" href="<?php bbp_forum_permalink(); ?>"> 
    <?php $forum = bbp_forum_id();  
    $parent = wp_get_post_parent_id($forum);
    if (!empty($parent)) {
       echo esc_html( get_the_title($parent) ) ;
       } 
       ?> : <?php bbp_forum_title(); ?></a>

    The result is that i got the id forum behind each forum title (on the main parents forums list) and on the subforum list (when i click on a forum on the forums list), i got the subforum id attached to parent title : subforum title


    Robin W
    Moderator

    @robin-w

    change

    $forum = bbp_forum_id() ;

    to

    $forum = bbp_get_forum_id() ;


    momomoko
    Participant

    @momomoko

    Perfect dear Robin

    Thank you very much

    btw : did i process in the good way to modify my bbpress template ?


    Robin W
    Moderator

    @robin-w

    The recommendation is that the file goes in a directory called ‘bbpress’ in the root of your child theme.

    ie wp-content/themes/%your-theme-name%/bbpress/xxx.php

    where %your-theme-name% is the name of your theme

    child theme root works as well, but in ‘bbpress’ just makes it more obvious which plugin’s template you have amended


    momomoko
    Participant

    @momomoko

    Thank you for your tips dear

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