getdave / Tanlinell

Boilerplate Wordpress theme for rapid development of new WP themes. Based on the great work of the _s ("Underscore") theme.
GNU General Public License v2.0
6 stars 2 forks source link

CPT menu item #245

Closed neilberry001 closed 10 years ago

neilberry001 commented 10 years ago

Add in suitable include. Adds current-menu-item to menu item for cpt's

function current_type_nav_class($classes, $item) {

    $post_type = get_post_type();
    $post_type_obj = get_post_type_object($post_type);

    if ($item->title == $post_type_obj->label) {

        array_push($classes, 'current-menu-item');

    };
    return $classes;
}
add_filter('nav_menu_css_class', 'current_type_nav_class', 10, 2 );