Created
February 13, 2013 21:02
-
-
Save billerickson/4948224 to your computer and use it in GitHub Desktop.
Add category ID to menu items.
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 | |
/** | |
* Category ID on Menu | |
* | |
* @author Bill Erickson | |
* @link http://www.billerickson.net/code/category-id-on-menu-items | |
* | |
* @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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment