Skip to:
Content
Pages
Categories
Search
Top
Bottom

BBPress Single Forum Menu Item


  • Evan Herman
    Participant

    @eherman24

    I have a forum I am setting up to support some plugins I’ve created. The forum is displayed on a ‘Support’ page. I also have a seperate ‘Blog’ page, which I use for blog posts.

    When a user clicks into a support thread, the navigation item changes from highlighting the ‘Support’ menu item to highlighting the ‘Blog’ menu item. From some research I’ve done it’s due to bbpress using single.php as its page template, which is setting the ‘Blog’ page the current page.

    How can I get this so ‘Support’ stays highlighted after clicking into a thread?

    Sorry if this is an easy fix, I’m new to bbpress and just getting used to the template hierarchy.

    Thanks!

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

  • Evan Herman
    Participant

    @eherman24

    Probably not the most elegant solution, but something I came up with to temporarily resolve the issue.

    First we grab the classes assigned to the body class:

    $body_class = get_body_class();

    Then we just check if bbpress is in the body class array, and if it is, I’ve decided to use jQuery to just switch the classes on the navigation item.

    
    if ( in_array('bbpress',$body_class) ) {
    		?>
    		<script>
    		  jQuery(document).ready(function() {
    		    jQuery('.menu-item-347').removeClass('current_page_parent');
    		    jQuery('.menu-item-2592').addClass('current_page_parent');
    		  });
    		</script>
    <?php
    	}
    

    We have a ticket in Trac for this here, no patch yet though.https://bbpress.trac.wordpress.org/ticket/2204


    ebarcena
    Participant

    @ebarcena

    I’m grad this issue is getting worked on.

    Hey Evan Herman can you please share your temporal solution code exactly as I should paste it in my functions.php

    I pasted it like this but nothing happened:

    $body_class = get_body_class();
    if ( in_array('bbpress',$body_class) ) {
    		?>
    		<script>
    		  jQuery(document).ready(function() {
    		    jQuery('.menu-item-347').removeClass('current_page_parent');
    		    jQuery('.menu-item-2592').addClass('current_page_parent');
    		  });
    		</script>
    <?php
    	}

    Thanks!

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

You must be logged in to reply to this topic.