• I have a ‘Docs’ menu item in my primary menu. I’d like to be able to highlight that with the help of the .current_page_parent class when the user is on a docs subpage.

    It’s not happening out of the box.

    Any recommendations for the best way to accomplish that?

    Thanks!
    Robert

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter rgilman

    (@rgilman)

    I’ve come up with the follow that seems to work:

    add_filter('nav_menu_css_class', 'bp_docs_is_parent', 10 , 2);
    
    function bp_docs_is_parent( $classes, $item) {
    	if (bp_docs_is_bp_docs_page() && $item->title == 'Docs' && bp_current_component() != 'groups') {
    		$classes[] = 'current_page_parent';
    	}
    	return $classes;
    }

    Is there a better way?

    Plugin Author David Cavins

    (@dcavins)

    That looks pretty good to me, and I would have suggested looking bp_docs_is_bp_docs_page() for starters, then adding conditionals, which you have done. If it works for you, there’s nothing wrong with your logic that I see.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add .current_page_parent for docs subpages?’ is closed to new replies.