I am trying to figure out how to add a custom menu item to the primary nav bar.
I am basically trying to incorporate a mega menu type thing using http://geedmo.github.io/yamm/, a mega menu built for bootstrap. I have it working, but I now need to be able to add the custom menu item to the primary nav - ideally in the last position of the
produced by wordpress and the roots nav walker.
I found some code and tried putting it in the nav.php file, but it just threw up an error, I’m not massively php savvy:
I changed the above bottom line from wp_nav_menu_items, but that didn’t work either.
Any pointers on this would be amazing. I’m sure there must be a relatively simple way of doing it, but I can’t find anything after hours of searching google.
If more info is required, or I need to explain better. I’m happy to do it!
You need to tell add filter how many arguments to expect. Also, instead of making up filters, you’re better off searching the codex for an explanation of the code.
Using Foxaii’s example I was able to add a list of authors to the main menu (working fine), but once I tried to do the same with categories, they get listed outside the main ul. Here’s the working code I’m using for Authors, and for Categories.
Any idea why the second one doesn’t echo the list inside the dropdown ul?
When adding this code exactly as is to extras.php I get the following error:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘add_last_nav_item’ not found or invalid function name in /Users/mike/Sites/Development/lendwise.local/html/web/wp/wp-includes/plugin.php on line 235