adding some custom html code to the wp_nav_menu function

To add that last list item, you don’t need a custom Walker. There is a hook that will allow you to tack that on.

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');

It wouldn’t be start_el and end_el that you’d need to edit anyway. Those generate the individual list items. It isn’t the place to add another item. I think you would probably need to go up to Walker_Nav_Menu‘s parent Walker class to get to a place where you can add new items but it isn’t worth the effort just to add items.

Leave a Comment