Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to set different menu for different page in wordpress

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 239
    Comment on it

    We can set different menu links for every page in wordpress. Sometimes we get the requirements from the client to have different menu links for every pages. It can be done, Its quite coding part. For each pages we have to set different menus from WordPress backend but WordPress themes do not have that option, they have a option to show one menu in all pages. Before setting up the menu , first we have to make different menus by writing a code in WordPress theme functions.php.

    In theme functions.php, you can search for menu function as different themes named the menu function in different way.

    You can copy the expressions inside the function and can paste it there only.

    e.g.

    register_nav_menus( array(
    'primary' =>; __( 'Primary Navigation', 'twentyten' ),
    'contactmenu' =>; __( 'contact menu', 'twentyten' ), // custom menu for contact page
    ) ); 
    

    \ After this, you will see the custom menu came in the wordpress backend under (Appearance-Menu)\

    You can set the menu from the backend for that particular page.

    After making menu you have to call that custom menu in that particular page. Open the header.php of the wordpress theme.and copy paste the below code

    <?php
    if( is_page('contact') ) { // if page is contact page it will show contact menu 
    wp_nav_menu( array( 'container' =>; '', 'container_class' =>; '', 'container_id' =>; '', 'items_wrap'      =>; '%3$s', 'theme_location' =>; 'contactmenu' ) ); } else { wp_nav_menu( array( 'container' =>; '', 'container_class' =>; '', 'container_id' =>; '', 'items_wrap'      =>; '%3$s', 'theme_location' =>; 'primary' ) );
    } ?>; 
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: