Skip to content

Commit

Permalink
add post type nav menu class filter
Browse files Browse the repository at this point in the history
  • Loading branch information
justindantzer committed Aug 14, 2015
1 parent faee940 commit e67ead8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions navigation.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
<?php // CUSTOM NAVIGATION


/*
* This can help fix an issue where the blog page is highlighted
* for archives/singles of other post types.
*/
add_filter('nav_menu_css_class', 'custom_post_type_nav_class', 10, 2);
function custom_post_type_nav_class($classes, $item){
$post_type = get_post_type();

if(!is_singular('post') && !is_category() && !is_tag() && $item->object_id == get_option('page_for_posts')){
unset($classes[array_search('current_page_parent', $classjes)]);
}

if(!is_search() && !is_404()){
if(in_array("post-type-{$post_type}", $classes)){
array_push($classes, 'current_page_parent');
}
}

return $classes;
} //EF


class customize_wp_nav_menu {

function __construct(){
Expand Down

0 comments on commit e67ead8

Please sign in to comment.