Answer the question
In order to leave comments, you need to log in
How to display wp_nav_menu inside HTML structure via shortcode?
Hello, I am making a plugin in which I collect a custom menu using the Walker class, then display it using the wp_nav_menu function through a shortcode. The task is to display the menu along with the following HTML structure:
<div id="main">
<div class="wrap1">
<div class="wrap2">
<div class="wrap3">
ТУТ САМО МЕНЮ
</div>
</div>
<div class="arrows">
тут некоторые теги управления
</div>
</div>
</div>
function my_function(){
$variable = '<div id="main"><div class="wrap1"><div class="wrap2"><div class="wrap3">';
$variable .= wp_nav_menu( 'тут массив аргументов меню' );
$variable .= '</div></div><div class="arrows"><i>некоторые теги управления</i></div></div></div>';
return $variable;
}
add_shortcode('menu-test','my_function');
Answer the question
In order to leave comments, you need to log in
wp_nav_menu(['echo' => false])
, m? :)
It displays it by default, but does not return it, so the menu is displayed first, then everything else.
Wow, exactly!
I had ['echo' => true], changed it to false and everything came out fine.
Thank you!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question