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 5 replies - 1 through 5 (of 5 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!


    jeroenheijmans
    Participant

    @jeroenheijmans

    Thanks for logging this issue. I had the same problem. I’ve solved it without PHP, just jQuery.

    For what it’s worth, here’s what it looks like:

    <script>
    jQuery(document).ready(function() {
        if (jQuery('#bbpress-forums')) {
            jQuery('.current_page_parent').toggleClass('current_page_parent').next().toggleClass('current_page_parent')
        }
    });
    </script>

    It deselects the “current page” and selects the next one (which is the forum page, for me) as current. But only if #bbpress-forums is on the page.

    I’ve added this to the footer.php file of my theme (GeneratePress), just before the </body> statement.

    Hackish, but given that it’s noted as a bug it’ll do for now.


    dltanner99
    Participant

    @dltanner99

    So, this issue was never resolved with bbpress? Here it is a year later, and I am having the exact same problem. Are you still suggesting that we come up with a workaround for the forum/blog highlighting problem? Take a look at my site at the link below:

    http://trilogusmediagroupco.ipage.com/edipros01/forums/

    I just need to know why such a straightforward problem is still happening.
    I am also using the Generate Press theme with bbpress. Was it ever addressed/resolved?

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