Skip to:
Content
Pages
Categories
Search
Top
Bottom

how does bbpress.org keep highlighting the current page?


  • pinkhare
    Participant

    @pinkhare

    I want to keep my menu navigation to present that they’re under the current page(menu), but bbpress doesn’t keep highlight on the menu to show the state when they go to individual topic or reply page.

    I would have wished that bbpress topic or reply would have a WordPress Template page to be linked like as a normal wordpress sub-pages so that I don’t need any workaround in the first place. In other words, all the bbpress topics or replies must be only displayed on the page that admin users created.

    created WP page slug: forums -> topics (all topics here) -> replies (all replies here)

    Anyway for now, how can I make the menu like this site?

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

  • tharsheblows
    Participant

    @tharsheblows

    For the topics archive showing all topics, you can use the shortcode [bbp-topic-index] on a normal WordPress page.

    “All replies” is slightly different. You could use the Recent Replies widget (https://codex.bbpress.org/widgets/) if you had a page with a widget for the content but if you wanted a proper archive page, I think you’d have to make a new template for it. I think it’s one of those things that if enough people ask for it, it might get prioritised for future versions but that’s just a guess. If you are comfortable making page templates, I can post how I did a “latest posts” page (posts = new topics + replies).

    I’m not sure what part of the menu you mean, I’m sorry. Do you mean how “support” (with a link to /forums) is highlighted above even when you’re on a topic page? They use a custom nav file:
    https://meta.trac.wordpress.org/browser/sites/trunk/buddypress.org/public_html/wp-content/themes/bb-base/header-nav.php

    If I were trying to replicate that, I would use jQuery to add the current-menu-item class to the top forums list item – not that it’s is the right way to do it, it would just be the easiest for me to do and to maintain. You’d need to add it to a javascript file in your template or make one and then include it. If you’re interested, I can post that code – you will need to add a custom class to your forums menu item too.

    Sorry, I know that wasn’t too terribly helpful!


    pinkhare
    Participant

    @pinkhare

    Thank you so much, tharsheblows! And your answer is very helpful to me.

    I also suppose your method is the right choice than the former which has a flurry of IF statements. Could you post your code for me, please?
    Thanks again. 🙂


    tharsheblows
    Participant

    @tharsheblows

    Sure – this is what I did on a test install. The current menu item class in mine is “current-menu-item” and I added a custom class “forum-class” to the forum menu item in my custom menu. I *always* forget that I need to unhide the css class input by ticking the box in “Screen options” at the top of the “edit menus” screen in admin. You probably don’t but I thought I’d mention. 🙂 Then I use that for the jQuery.

    So:

    1 – add “forum-class” to your forums menu item in your custom menu
    2 – add this to your js file with YOURURL = the url of your site and forums = your forums slug :

    $(function() { 
    	      var forumURL = window.location.href.indexOf("YOURURL/forums/");
    	      if(forumURL > -1){
    	      	$('li.forum-class').addClass('current-menu-item');
    	      }
    	}); 

    nb: addClass won’t add duplicate classes so no need to test if it’s already there.


    pinkhare
    Participant

    @pinkhare

    Thank you so much! I’ll try it.


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Our navigation is custom built into the header template.


    David13_13
    Participant

    @david13_13

    I have the same problem and I have tried the solution of user tharsheblows and the problem continue…

    Some other fix please?

    Thanks in advance

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