hey all,
i’m writing an automated function that generates a menu from a function. it calls wp_nav_menu on each item from an array, because i want this to be dynamic. the problem is, no matter how i set it, if the menu doesn’t exist, wp_nav_menu is generating a menu, eg the ‘default’. here is my code (items is just a set of strings):
for($i=0;$i<count($items);$i++) {
$themenu=$items[$i];
$mymenu = wp_nav_menu(array(
'menu' => $themenu,
'menu_class' => 'mymenu',
'container' => 'false',
'fallback_cb' => 'false',
'echo' => false
)
);
echo $themenu;
}
i know its partially working, because if $themenu exists, it shows the correct one. but if it doesn’t, it’ll just show any menu! not just annoying, but also actively breaks the user experience.