Skip to content

Instantly share code, notes, and snippets.

@DenisLeblanc
Created July 10, 2014 20:54
Show Gist options
  • Save DenisLeblanc/0067cbd9dc451df30da2 to your computer and use it in GitHub Desktop.
Save DenisLeblanc/0067cbd9dc451df30da2 to your computer and use it in GitHub Desktop.
Fix Blog Tab Classes on Custom Post Type Pages
<?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