admin管理员组文章数量:1414621
I am searching for a way to display a different menu according to postID:
ex:
if ($post->ID == 2309) {
displayMenu("menu2");
}
I am using Avada and looked into header.php with no success.
I am searching for a way to display a different menu according to postID:
ex:
if ($post->ID == 2309) {
displayMenu("menu2");
}
I am using Avada and looked into header.php with no success.
Share Improve this question asked Sep 9, 2019 at 10:57 yarekyarek 1274 bronze badges1 Answer
Reset to default 0You can use wp_nav_menu($args)
to display different menus. Just pass menu ID, slug, name or object as $args['menu']
parameter.
if ( $post->ID == 2309 ) {
$args = array(
'menu' => 'some-menu'
);
wp_nav_menu($args);
}
There are also other available parameters that you can pass to the function, https://developer.wordpress/reference/functions/wp_nav_menu/
本文标签: how to display different menu according to postid
版权声明:本文标题:how to display different menu according to postid? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745173494a2646116.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论