Created
July 10, 2014 20:54
-
-
Save DenisLeblanc/0067cbd9dc451df30da2 to your computer and use it in GitHub Desktop.
Fix Blog Tab Classes on Custom Post Type Pages
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
<?php | |
// FIX BLOG TAB CLASSSES ON CUSTOM POST TYPES | |
function fix_blog_tab_on_cpt( $classes, $item, $args ) { | |
if( !is_singular( 'post' ) && !is_category() && !is_tag() ) { | |
$blog_page_id = intval( get_option( 'page_for_posts' ) ); | |
if( $blog_page_id != 0 ) { | |
if( $item->object_id == $blog_page_id ) { | |
unset( $classes[ array_search( 'current_page_parent', $classes ) ] ); | |
} | |
} | |
} | |
return $classes; | |
} | |
add_filter('nav_menu_css_class','fix_blog_tab_on_cpt',10,3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment