In my recent project i have to create the second level menu
it will be pleasure for me to share with you.
For it first of all we will have to declare or register the custom menu in the function.php
There are steps to create custom menu in wordpress
1. creating the function for register the menu
that function will be created in function.php
that is in theme directory
and will write function such as
first of all we will initialize function as below
add_action( 'init', 'joyrelish_menus' );
function joyrelish_menus() {
register_nav_menus(
array(
'primary-menu' => __( 'Primary Menu' ),
'secondary-menu' => __( 'Secondary Menu' )
)
);
}
Now for it you can see the secondary menu in WordPress through wp-admin
go to appearance->menu
it will be pleasure for me to share with you.
Creating custom menu
For custom menu we will have to create the functionFor it first of all we will have to declare or register the custom menu in the function.php
There are steps to create custom menu in wordpress
1. creating the function for register the menu
that function will be created in function.php
that is in theme directory
and will write function such as
first of all we will initialize function as below
add_action( 'init', 'joyrelish_menus' );
function joyrelish_menus() {
register_nav_menus(
array(
'primary-menu' => __( 'Primary Menu' ),
'secondary-menu' => __( 'Secondary Menu' )
)
);
}
Now for it you can see the secondary menu in WordPress through wp-admin
go to appearance->menu
you will see the secondary menu with the primary menu
Through selected the secondary menu
create the new menu
select he page post or something else for he menu
then you can see or call that secondary navigation through the code
in the header.php or the file in which you are going to call that secondary menu
add below code to show the secondary menu
<?php wp_nav_menu( array( 'theme_location' => 'secondary-menu', 'menu_class' => 'secondary_menu_joyrelish'') ); ?>
Then will see the secondary menu ..
No comments:
Post a Comment