作为一个记录,感觉以后可能会需要用到
1 2 3 4 5 6 7 8 9 10 |
function wpse_218377_nav_menu_css_class( $classes, $item, $args ) { if ( ! empty( $args->theme_location ) && $args->theme_location === 'custom-menu' ) { $classes[] = 'footer--menu-item'; } // ALWAYS return, not from inside the if return $classes; } add_filter( 'nav_menu_css_class' , 'wpse_218377_nav_menu_css_class' , 10, 3 ); |
钩子地址: https://developer.wordpress.org/reference/hooks/nav_menu_css_class/