Creating WordPress Menus

You also need to create dynamic menus in WordPress. WordPress provides function for menus. You can create one single menu to any number of menus you need to create. First of all you need to define theme_support for menus. For that open up your your function file and after the function we created earlier add following code. This will enable to menus for you.

add_theme_support( 'menus' );

Now our theme supporting for menus. Before you the menu you need to register the menu. Add following code to the function file after the above code.

register_nav_menus( array( 'main' => 'Main Nav' ) );

Now this menu has been created. You can simply create your menu by navigating to Appearance > Menus. Now give the your menu name and create menu. It will be showing up you the menu location, just select what we have defined. Tick location main for your menu.

Now you have created your menu and only you have to display that menu in front end. For that there is a function called wp_nav_menu() and it has many more options. It is better to refer Codex for Navigation Menus.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *