Skip to content

Instantly share code, notes, and snippets.

@AnatoliyAkhmatov
Created September 11, 2020 05:23
Show Gist options
  • Save AnatoliyAkhmatov/b27518f28c5256e803a987955e1fc697 to your computer and use it in GitHub Desktop.
Save AnatoliyAkhmatov/b27518f28c5256e803a987955e1fc697 to your computer and use it in GitHub Desktop.
$args = array(
'container' => '',
'theme_location'=> 'your-theme-loc',
'depth' => 1,
'fallback_cb' => false,
'add_li_class' => 'your-class-name1 your-class-name-2'
);
wp_nav_menu($args);
function add_additional_class_on_li($classes, $item, $args) {
if(isset($args->add_li_class)) {
$classes[] = $args->add_li_class;
}
return $classes;
}
add_filter('nav_menu_css_class', 'add_additional_class_on_li', 1, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment