Dawn Seeker
Dawn Seeker

Reputation: 37

Getting a specific Menu from wordpress to php

I have 3 menus created in WordPress and the main menu is retrieved using wp_nav_menu() . I also want to retrieve the other menu please guide me how to do so.

Upvotes: 0

Views: 2079

Answers (3)

paras adeshra
paras adeshra

Reputation: 36

To retrieve other menu, you need to pass argument menu with menu name like this:

wp_nav_menu( array( 'menu' => 'name of the menu' ) );

Upvotes: 2

Nidhi Patel
Nidhi Patel

Reputation: 396

You are able to create custom menu in your theme. Add this code to the function.php of your theme.

function lanparts_menu_setup(){
    add_theme_support('menus','woocommerce');       
    register_nav_menu('woocommercemenu','Woocommerce Menu Navigation');
}

add_action('after_setup_theme','lanparts_menu_setup');

for more detail that follow this link

Upvotes: 2

Neal Developer
Neal Developer

Reputation: 595

You need to pass it an args array, and declare the theme_location key.

wp_nav_menu( array(
    'theme_location' => 'header_main'
) ):

and

wp_nav_menu( array(
    'theme_location' => 'header_secondary'
) ):

Upvotes: 3

Related Questions