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') );
}
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