Category ID on Menu Items

* Category ID on Menu
* @author Bill Erickson
* @link
* @param array $classes
* @param object $item
* @return array $classes
function be_category_id_on_menu( $classes, $item ) {
if( $item->object !== 'category' )
return $classes;
$classes[] = 'menu-item-category-' . $item->object_id;
return $classes;
add_filter( 'nav_menu_css_class', 'be_category_id_on_menu', 10, 2 );
view raw functions.php hosted with ❤ by GitHub

Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk