Hi John,
WordPress has this filter – wp_nav_menu_items
: https://developer.wordpress.org/reference/hooks/wp_nav_menu_items/
You can use this filter to alter the menu. So for instance, one very simple way to do it is through something like this:
add_filter( 'wp_nav_menu_items', 'prefix_add_div', 15, 2 );
function prefix_add_div( $items, $args ) {
if( $args->theme_location != 'primary' ) {
return $items;
}
$myreplace1 = '</a>';
$myinsert1 = '<span>MY span</span></a>';
$items = str_replace( $myreplace1, $myinsert1 , $items );
return $items;
}