I have a website that has a main menu(Top-Horizontal) like this:

Main menu
 - Home
 - About Us
 - contact us

On Home page I have a link to "Company" page like this www.xyz.com/company.

When I am on this company page I want my website to chnage my menu items and use this:

Different menu
 - Home (same Home page link that will take user to www.xyz.com)
 - promoters
 - Gallery
 - Maps

I think i can do this using wordpress Conditional_Tags, but really dont know how should I start.


5 Answers 5


You can try it this way. Now we are talking about pages you can set up a separate template for the page that needs a different menu. This where WordPress's newer menu feature is really nice.

First if you are using the newer menu feature of WordPress place this in place of your current menu:

<?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>

Next put this at the top of the template file that you are going to use for the page. This tells WordPress that this is a page template.

 Template Name: Name your template here

Then place this in your template where your menu should go for this template:

<?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' =>    'template_menu' ) ); ?>

Now we have to make sure that they will be activated. In your theme's functions.php file you will need to place this:

// This theme uses wp_nav_menu() in two locations.  
register_nav_menus( array(  
  'primary' => __( 'Primary Navigation', 'your_theme_name' ),  
  'template_menu' => __('Template Navigation', 'your_theme_name')  
) ); 

Once this is all done all you need to do is go to your dashboard > Appearance > Menu and create your menus there. Once created save then on the left it will give you the option of where to place which menu where via the drop downs.

After all this is set up when you set up a new page all you have to do is select the template you want to use.

I hope this helps if you have questions just ask.


Diferent menu in diferents pages using custom field in page --> functions.php

function shortcode_nav_menu_args( $args = '' ) {
    //if exist custom fiel cp_menu in page gets the id of menu (number)
    //else gets the default menu
    $menu = get_post_meta(get_the_ID(), 'cp_menu', true);
    if(isset($menu)) { 
        $args['menu'] = $menu; 
    return $args;
add_filter( 'wp_nav_menu_args', 'shortcode_nav_menu_args' );

You can use the free plugin Conditional Menus. I use it on my projects and it always works like a charm!


Conditional tags would liekly be the way froward. How are you calling your menu? wp_list_pages() I assume?

If so, you can make use of the exclude argument, using something like below (obviously tweek the page numbers and the conditional tags to your needs) -

if(is_front_page()) :
    $exclude = '10,11,12';
elseif(is_page(15)) :
    $exclude = '1,2,3';
wp_list_pages('title_li=&depth=1&exclude=' . $exclude);
  • But my file has this code wp_list_pages('title_li=&depth=0&exclude=' . get_inc_pages("pag_exclude_") .'&sort_column=menu_order'); ?>
    – Anshul
    Nov 10, 2011 at 6:56

There is a plugin for this that looks promising.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.