Skip to content

Instantly share code, notes, and snippets.

@macariojames
Created February 21, 2020 21:26
Show Gist options
  • Save macariojames/880414c4724cfbf058b007a91f7845ab to your computer and use it in GitHub Desktop.
Save macariojames/880414c4724cfbf058b007a91f7845ab to your computer and use it in GitHub Desktop.
Remove all classes from anchors in navwalker menus (WordPress)
//Put this in your functions.php or custom functionality plugin
// remove all classes from anchors in menus ~mj
function mj_remove_classes_from_all_menu_anchors( $atts ) {
$atts['class'] = ''; // not it's blank; if you add classes like 'example1 class2', it'll add classes ~mj
return $atts;
}
add_filter( 'nav_menu_link_attributes', 'mj_remove_classes_from_all_menu_anchors', 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment