how to display different menu according to postid?

I am searching for a way to display a different menu according to postID: ex: if ($post->ID == 2309) {displayMenu(&qu

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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

You 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

相关推荐

  • how to display different menu according to postid?

    I am searching for a way to display a different menu according to postID: ex: if ($post->ID == 2309) {displayMenu(&qu

    1小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信