Skip to content

Instantly share code, notes, and snippets.

@Trovin
Last active July 31, 2019 15:03
Show Gist options
  • Save Trovin/e3563f54bdb4aaa4619b599a01368ebe to your computer and use it in GitHub Desktop.
Save Trovin/e3563f54bdb4aaa4619b599a01368ebe to your computer and use it in GitHub Desktop.
WP add class to primary menu item
IN FUNCTIONS.PHP
----------------
/**
* Add class to primary menu item.
*/
function atg_menu_classes($classes, $item, $args) {
if($args->theme_location == 'menu-1') {
$classes[] = 'main-nav__item';
}
return $classes;
}
add_filter('nav_menu_css_class','atg_menu_classes',1,3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment