Many times you install a theme which either do not support a custom wordpress menu or have only one wordpress custom menu and you wish to add a custom wordpress drop down menu to the theme but you don’t know how. Don’t worry i am here to assist you on this problem.
Here i am going to tell you, how you can add a new custom wordpress menu to your theme at any location you want.
Adding a wordpress menu drop down to any wordpress theme have three basic steps:-
1) Register the wordpress custom menu
2) Display the wordpress drop down menu
3) Writing the CSS of the menu
1) Register the wordpress custom menu :-
Write this code in the funtions.php file of the theme.
1 2 3 4 5 6 7 8 | if (function_exists('register_nav_menus')) { register_nav_menus( array( 'menu1' => 'menu1 description' , 'menu2' => 'menu2 description' ) ); } |
By using this function you can register any number of menus. Just add an item in the array key as menu slug and value as the menu description.
2) Display the wordpress drop down menu :-
Write this code where you want to display the menu in the theme like in your header file or footer file.
1 2 3 4 5 | //default arguments $args = array( 'theme_location' => "menu1" //slug of the menu to display ); wp_nav_menu( $args ); |
3) Writing the CSS of the menu :-
Now this is the third and last step, write down the css of this menu in your stylesheet
Hi, Nice Info, Also many times when we install a theme, the Stylesheet comes missing from the package. How to deal with that?
Hello Gaurav,
Wordpress identify the theme and its related information(like theme name,author name, version etc.) from style.css
If it is showing that stylesheet is missing at the time of installation then please check the style.css file exist in the parent directory of the zipped theme.
If it exist at right place then please open it and check whether the information is correctly defined there at top like this:-
Many thanks again for your quick reply, It will be helpful to me and a lot others too.