Skip to:
Content
Pages
Categories
Search
Top
Bottom

Conditional for bbpress home


  • Martin J
    Participant

    @mocha365

    Hopefully I got the right forum here.

    I want to add a heading when on the “forums” archive home page of the bbpress forum. Right now I have this for jetpack’s portfolio…note this is just a snippet of my code:

    if (is_post_type_archive()) :
    echo '<h1 id="bts-page-title">' . __( 'WordPress Themes', 'bts' ) . '</h1>';

    …but the bbpress forum header area is loading that title as well. I’ve tried so many variations and conditionals, none work. I did manage to get the “forum” titles to show for individual forums with:

    elseif (is_bbpress('forum') ) :
    echo '<h1 id="bts-page-title">' . __( 'Support Forum', 'bts' ) . '</h1>';

    But does anyone have an idea how to get the conditional to show a custom header title for the bbpress home page?

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

  • Robin W
    Moderator

    @robin-w

    simplest way would be to

    create a page with a permalink of ‘forums’ (assuming that is what your forums are called in dashboard>settings>forums>forum root slug>forum root)

    but with a title of whatever you want the forum page to be called

    and just put this shortcode in it

    [bbp-forum-index]

    That should work


    Martin J
    Participant

    @mocha365

    Not quite what I was looking for in way of “conditionals” but I have to admit your method (albeit unconventional) worked like a charm, although my custom CSS for bbpress is not inherited. I will need to see about fixing the custom css styles.

    Anyway, thanks.


    Martin J
    Participant

    @mocha365

    Update: I had this in my functions:

    if ( is_bbpress()) {
    ….etc.

    But adding:

    is_page()

    Means that the custom-bbpress.css is going to load on all “pages”. A temporary solution, but not really the right solution.


    Martin J
    Participant

    @mocha365

    Ah….found a fix for the above/last reply. I added the id of the page, so now the custom-bbpress.css only loads for bbpress and that page.

    if (is_bbpress() || is_page( 209 ) ) :


    Robin W
    Moderator

    @robin-w

    great – glad you are fixed !


    Martin J
    Participant

    @mocha365

    Actually…. the solution above wasn’t going to work because if breadcrumbs are enabled and someone clicks on the “Forum Home”, we lose all the effort. However, I finally found the conditional statement that works.

    This is only part of my code, but you can get the idea…I originally had this:

    
    // For Jetpack Portfolio heading
    elseif (is_post_type_archive()) :
    echo '<h1 id="bts-page-title">' . __( 'WordPress Themes', 'bts' ) . '</h1>';
    
    // For bbpress forum heading
    elseif (is_bbpress('forum')) :
    echo '<h1 id="bts-page-title">' . __( 'Support Forum', 'bts' ) . '</h1>';

    However, when I did this, it worked:

    // For bbpress forum heading
    elseif (is_bbpress('forum') || is_post_type_archive('forum') ) :
    echo '<h1 id="bts-page-title">' . __( 'Support Forum', 'bts' ) . '</h1>';
    
    // For Jetpack Portfolio heading
    elseif (is_post_type_archive()) :
    echo '<h1 id="bts-page-title">' . __( 'WordPress Themes', 'bts' ) . '</h1>';

    Now what is interesting, is that if I have the bbpress conditional “after” the Jetpack portfolio one, it would not work and the bbpress heading would be “WordPress Themes”. However, I had this sudden thought that perhaps there is a priority happening here, so I moved the bbpress conditional “before” the Jetpack one, and sure enough it works. The bbpress heading is “Support Forum” and the Jetpack portfolio is “WordPress Themes”.

    Something about the sequence caused an issue…what and why I do not know.

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