0

So I have a couple of already created menus on my wordpress installation. What I am planning to do is display navigation menus in a sliding popup. I have tried using wp_nav_menu() but it always shows the first (alphabetically) menu instead of the one I want displayed.

$args = array
 (
'menu_id' => $short,
'menu_class' => 'menu',
'fallback_cb' => false
 );
wp_nav_menu( $args);

$short is getting the menu name from the URL. As far I have understood the wp_nav_menu function I need to add code to the functions.php as well. Is that correct? I feel like in my usecase that's not the best way to solve the problem, as I want to create 25 sliding navs via PHP. If I have to add code to the functions.php as well for each menu I can do the whole task manually. Thank you

1 Answer 1

0

I found the solution.

I had to do the following

$args = array
(
'theme_location' => $short,
'menu_id' => $short,
'menu_class' => 'menu',
'menu_id'=>$menu_id,
'fallback_cb' => false
 );
wp_nav_menu( $args);

Theme location was the correct attribute.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.