Sunday 17 July 2016

Register a Custom Menus Location In WordPress

To register a custom Menu location you must use the following function for registration.

register_nav_menu( $location, $description );
$location - The location where you want to display the menu in your theme (e.g.) - Primary,Secondary,Main Header etc.,
$description - The Description about the menu Location and the Menu.

Step: 1 Add the following lines in the function.php file.
function register_menu() {
    register_nav_menu('primary-menu', __('Primary Menu'));
}
add_action('init', 'register_menu');

Step: 2 Add the following lines in the file where you want the menu to display.

if ( has_nav_menu( 'primary-menu' ) ) { /* if menu location 'primary-menu' exists then use custom menu */
      wp_nav_menu( array( 'theme_location' => 'primary-menu') );
}

No comments:

Post a Comment

Email Code PHP

This is a Simple Code which is written in the PHP for Sending Emails from One Server to all the Other Domains. It is very easy and little C...