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/
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745173495a4615069.html
评论列表(0条)