nav_menu_css_class Missing argument 2
-
I’m trying to add some classes to my menu items… I see that the Walker_Nav_Menu calls apply_filters with the ‘nav_menu_css_class’ tag and two arguments ( $classes and $item )
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
Nevertheless, filter function receives only one argument, i.e. only the $classes array
function my_nav_menu_css_class( $classes = array(), $item ) { echo "\n<!-- func_get_args: \n"; print_r( func_get_args() ); echo "\n-->\n"; return $classes; } add_filter( 'nav_menu_css_class', 'my_nav_menu_css_class' );
keeping the second argument in my function results in “missing argument 2” warning and the value of $item is NULL
… thus to achieve a simple task of adding classes I have to use a Walker class (which works fine) but it should NOT need to be necessary
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘nav_menu_css_class Missing argument 2’ is closed to new replies.