Last active
November 3, 2023 18:03
-
-
Save morgyface/aeea84211991f8e671616d3800647c3c to your computer and use it in GitHub Desktop.
WordPress - Custom menu item and menu link classes using nav filters
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add custom classes to wp_nav_menu
This has been a long, lingering frustration of mine; wp_nav_menu allows us to add classes to containers and wrappers, but we have no option to add classes to the items and links within those containers. We're forced to use
menu-itemandain our css. Here's where these neat filters come in. Add them to your theme's functions file and then reference them in your templates (typically header or footer includes) as illustrated below in the example.Reference here: