menus – Can I insert elements anywhere into the results of wp_nav_menu()?

Question

I know that it’s easy to add something to the end of a navigation menu using code like the below:

function add_last_nav_item($items) {
  return $items .= '<li><a href="#myModal" role="button" data-toggle="modal">Contact</a></li>';
}
add_filter('wp_nav_menu_items','add_last_nav_item');

However, I need to do something that appears to be more complex.

I have 4 main menus each with child menu items. I need to add an entry to the bottom of the 3rd menu.

Is this possible in PHP having received a menu via wp_nav_menu() ?

0
AdamJones 5 months 2021-06-22T17:37:04-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse