Skip to content

Instantly share code, notes, and snippets.

@kfriend
Created November 13, 2014 14:54
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 kfriend/c44ff411f1f9b65ff8b2 to your computer and use it in GitHub Desktop.
Save kfriend/c44ff411f1f9b65ff8b2 to your computer and use it in GitHub Desktop.
Wordpress: Custom post type active nav workaround
<?php
add_filter('nav_menu_css_class', function($classes, $item) {
switch (get_query_var('post_type')) {
case 'custom_post_type_name':
if ($item->object_id == THE_ID_FOR_THE_NAV_ITEMS_TARGET_PAGE) {
$classes = array_diff($classes, array('current_page_parent'));
}
break;
}
return $classes;
}, 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment