In the backend of wordpress, Goto Appearance->Menus and add your custom menus for primary navigation and save it.
This is only for primary navigaton. Then how to create another navigation? Its pretty simple!. Click the '+' sign tab near the primary navigation on top. Then in the Menu Name enter the new name of the navigation in the text box and click Create Menu.
Voila! New navigation is created. Now you can add your custom menus to that navigation. But in the front end it shows only primary navigation.
Where is the navigation which I created now ? Don't freak out! We have to call the navigation in our theme file at the place we are displaying..
Open your wordpress wp-content\themes\header.php and find the php function wp_nav_menu();. This is where your navigation displays in your site.
Now you need to display another navigation in your site. So just copy that navigation code(wp_nav_menu()--totally) and paste where You need another navigation. Then go to your admin backend of Appearance->Menus again and inspect Theme locations select box in your firebug or whatever.Clearly shown in image!!
You'll find the navigation created by us in the option like this
<option value="5">secondary navigation</option>
Note that value of our navigation and goto code where we left off. Now paste that value inside that wp_nav_menu() function with 'menu' as a key like this:
<?php wp_nav_menu( array( 'theme_location' => 'primary','menu' => '5' ) ); ?>
Here 5 is the value we are passing to display that navigation.
That It! Save the file and check the site.
This is only for primary navigaton. Then how to create another navigation? Its pretty simple!. Click the '+' sign tab near the primary navigation on top. Then in the Menu Name enter the new name of the navigation in the text box and click Create Menu.
Voila! New navigation is created. Now you can add your custom menus to that navigation. But in the front end it shows only primary navigation.
Where is the navigation which I created now ? Don't freak out! We have to call the navigation in our theme file at the place we are displaying..
Open your wordpress wp-content\themes\header.php and find the php function wp_nav_menu();. This is where your navigation displays in your site.
Now you need to display another navigation in your site. So just copy that navigation code(wp_nav_menu()--totally) and paste where You need another navigation. Then go to your admin backend of Appearance->Menus again and inspect Theme locations select box in your firebug or whatever.Clearly shown in image!!
You'll find the navigation created by us in the option like this
<option value="5">secondary navigation</option>
Note that value of our navigation and goto code where we left off. Now paste that value inside that wp_nav_menu() function with 'menu' as a key like this:
<?php wp_nav_menu( array( 'theme_location' => 'primary','menu' => '5' ) ); ?>
Here 5 is the value we are passing to display that navigation.
That It! Save the file and check the site.
No comments:
Post a Comment