admin管理员组文章数量:1391995
I have Menu created by wp_nav_menu. Inside it, I want to set dynamic_sidebar but wp_nav_menu instead of displaying the content, throws 1.
Have everyone some tips for display sidebar inside wp_nav_menu? I have to add dynamic_sidebar inside menu it's important.
Inside walker I placed the code:
$item_output .= '
<div class="recipes__dropdown">
<div class="container">
<div class="dropdown__content">
<div class="row">' . dynamic_sidebar( 'recipes-dropdown' ) . '</div>
</div>
</div>
</div>';
Have you any suggestions how include dynamic sidebar inside wp_nav_menu?
I have Menu created by wp_nav_menu. Inside it, I want to set dynamic_sidebar but wp_nav_menu instead of displaying the content, throws 1.
Have everyone some tips for display sidebar inside wp_nav_menu? I have to add dynamic_sidebar inside menu it's important.
Inside walker I placed the code:
$item_output .= '
<div class="recipes__dropdown">
<div class="container">
<div class="dropdown__content">
<div class="row">' . dynamic_sidebar( 'recipes-dropdown' ) . '</div>
</div>
</div>
</div>';
Have you any suggestions how include dynamic sidebar inside wp_nav_menu?
Share Improve this question asked Oct 2, 2018 at 10:00 IgorIgor 132 bronze badges2 Answers
Reset to default -1You can add extra items in menu like
add_filter( 'wp_nav_menu_items', 'your_custom_menu_item', 10, 2 );
function your_custom_menu_item ( $items, $args ) {
if ($args->theme_location == '[YOUR-MENU-LOCATION]') {
$items .= '--YOUR EXTRA STUFF HERE--';
}
return $items;
}
Hope it will help!
The point is that dynamic_sidebar
does echo
and we need to get its content not echo
it inside wp_nav_menu
.
Try to do like this:
ob_start();
$sidebar = dynamic_sidebar( 'recipes-dropdown' );
$sidebar = ob_get_contents();
$item_output .= $sidebar;
ob_end_clean();
This helped me to make it work.
本文标签: menusDynamicsidebar inside wpnavmenu
版权声明:本文标题:menus - Dynamic_sidebar inside wp_nav_menu 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744643568a2617261.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论