0

I try to use wp_nav_menu in my website. My menu structure following like

 Home
 About
 Insight 
   Test
   Test
 About2
   Test
   Test

When i call menu using like this

       <?php
            // Primary navigation menu.
            wp_nav_menu(
            'menu_class'     => 'main-nav navbar-nav ml-auto',
            'container' => false,
            'theme_location' => 'header-menu',
                //'items_wrap'      => '<ul>%3$s</ul>',
                'depth' => 4,
            //
             );

        ?>

All main and sub menu view home page how to stop this

2
  • 3
    what do you want to say here? Commented Jun 11, 2018 at 10:13
  • How did you register the nav menu? register_nav_menu() Commented Jun 11, 2018 at 11:12

1 Answer 1

2

You forgot to call the array.

<?php
// Primary navigation menu.
wp_nav_menu( array(
    [
        'menu_class' => 'main-nav navbar-nav ml-auto',
        'container' => false,
        'theme_location' => 'header-menu',
        //'items_wrap'      => '<ul>%3$s</ul>',
        'depth' => 4,
        //
    ]
)  );
?>
Sign up to request clarification or add additional context in comments.

2 Comments

My main wp_nav_menu is called header-menu and that menu like this Home About Insight Test1 Test1 About2 Test Test I want to call this menu in home page without showing sub items . That can i do using <?php wp_nav_menu( array( 'menu_class' => 'main-nav navbar-nav ml-auto', 'container' => false, 'theme_location' => 'header-menu', 'depth' => 1, ) );?> But after when i go to the Insight page i want to show secondary main menu and secondary menu (only test1 and test2) How can i do this
I'm not sure how experienced you are with coding or PHP in general, so picking up some good basics might be a good idea before proceeding do some tutorials on the topic. That being said, if you want a secondary menu on the next page you need to call up a new array on that page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.