Skip to content

Instantly share code, notes, and snippets.

@generatepress
Created April 19, 2015 07:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save generatepress/7752e14657e806b63473 to your computer and use it in GitHub Desktop.
Save generatepress/7752e14657e806b63473 to your computer and use it in GitHub Desktop.
Possible fix for blog menu current highlighting with other post types
add_filter('nav_menu_css_class', 'generate_cpt_active_menu', 400);
function generate_cpt_active_menu($menu) {
$post_type = get_post_type();
switch($post_type) {
// Replace gallery with the name of your custom post type
case 'gallery':
$menu = str_replace('current-menu-item', '', $menu);
$menu = str_replace('current_page_item', '', $menu);
break;
}
return $menu;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment