Make sure that current_page_item class is added to menus. Particularly useful for create sub navigation for a CPT because be default WP doesn't add the current class to wp_list_pages() output when used with CPT.
/**
* Add "current" Page Class to Menus
* read more at:
* http://wordpress.stackexchange.com/questions/6333/adding-class-current-page-item-for-custom-post-type-menu
*
*/
function tanlinell_page_css_class( $css_class, $page ) {
global $post;
if ( $post->ID == $page->ID ) {
$css_class[] = 'current_page_item';
}
return $css_class;
}
add_filter( 'page_css_class', 'tanlinell_page_css_class', 10, 2 );
Make sure that current_page_item class is added to menus. Particularly useful for create sub navigation for a CPT because be default WP doesn't add the current class to
wp_list_pages()
output when used with CPT.