Last active
November 11, 2015 08:05
-
-
Save generatepress/f5e4f6d1795cf6bb4c6a to your computer and use it in GitHub Desktop.
Remove the current menu parent class from the Blog menu item when on the bbPress forum page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generate_remove_bbpress_parent_classes($class) | |
{ | |
return ( $class == 'current_page_parent' ) ? FALSE : TRUE; | |
} | |
add_filter( 'nav_menu_css_class', 'generate_remove_bbpress_parent_class' ); | |
function generate_remove_bbpress_parent_class( $classes ) | |
{ | |
switch (get_post_type()) | |
{ | |
case 'forum': | |
// we're viewing a custom post type, so remove the 'current_page_parent' from all menu items. | |
$classes = array_filter($classes, "generate_remove_bbpress_parent_classes"); | |
break; | |
case 'topic': | |
// we're viewing a custom post type, so remove the 'current_page_parent' from all menu items. | |
$classes = array_filter($classes, "generate_remove_bbpress_parent_classes"); | |
break; | |
} | |
return $classes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment