admin管理员组文章数量:1297050
I have a shortcode that will put a menu where I want it, but it only works on the primary menu. I don't want to use the shortcode for the primary menu, I would like to create a new menu called shortcodemenu and have the shortcode call it when it is used.
function print_menu_shortcode($atts, $content = null) {
extract(shortcode_atts(array( 'name' => null, 'class' => null ), $atts));
return wp_nav_menu( array( 'menu' => $name, 'menu_class' => $class, 'echo' => false ) );
}
add_shortcode('shortcodemenu', 'print_menu_shortcode');
I have a shortcode that will put a menu where I want it, but it only works on the primary menu. I don't want to use the shortcode for the primary menu, I would like to create a new menu called shortcodemenu and have the shortcode call it when it is used.
function print_menu_shortcode($atts, $content = null) {
extract(shortcode_atts(array( 'name' => null, 'class' => null ), $atts));
return wp_nav_menu( array( 'menu' => $name, 'menu_class' => $class, 'echo' => false ) );
}
add_shortcode('shortcodemenu', 'print_menu_shortcode');
Share
Improve this question
asked Sep 1, 2017 at 11:19
cboycboy
371 silver badge5 bronze badges
1 Answer
Reset to default 0You basically have everything set. You simply need to call the shortcode:
[shortcodemenu menu="slug-of-your-menu"]
Remember to use the SLUG of the menu you want to show instead of its name.
本文标签: Primary menu shortcode name
版权声明:本文标题:Primary menu shortcode name 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741641948a2389969.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论