I have a primary menu registered and displayed that consists of 4 links (home, about, news, blog). I want to add html (a logo) in between the second and third menu and I was
I solved similar problem this way:
add_filter('wp_nav_menu_items','add_custom_in_menu', 10, 2);
function add_custom_in_menu( $items, $args )
{
if( $args->theme_location == 'primary' ) // only for primary menu
{
$items_array = array();
while ( false !== ( $item_pos = strpos ( $items, '- custom HTML here
'); // insert custom item after 2nd one
$items = implode('', $items_array);
}
return $items;
}
Please notice, it works only for single-level menu.