Inject Menu Item into a Specific WordPress Menu
Navigation, WordPress
The ‘wp_nav_menu_items’ WordPress filter allows you to filter the HTML list content for nav menus.
The filter can accept up to two parameters:
- The HTML list content (
<li>
s) - An object containing
wp_nav_menu()
arguments
Passing in the second parameter allows you to target the nav menu. The following code appends a new menu item to the ‘Primary Navigation’ menu:
References
comments powered by Disqus