自定义WordPress菜单项默认的类
将下面代码添加到当前主题functions.php中,可以自定义WordPress 菜单项默认的类(class ):
- add_filter( ‘nav_menu_css_class’, ‘menu_item_classes’, 10, 4 );
- function menu_item_classes( $classes, $item, $args, $depth ) {
- unset($classes);
- $classes[] = ‘current-menu-ancestor’;
- return $classes;
- }