Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
    
There is a plugin that does exactly what you need. Try this: wordpress.org/extend/plugins/widget-logic –  user26828 Jan 31 '13 at 18:14
add comment

2 Answers

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.

<?php
/*
 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.

share|improve this answer
add comment

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) -

<?php
if(is_front_page()) :
    $exclude = '10,11,12';
elseif(is_page(15)) :
    $exclude = '1,2,3';
endif;
wp_list_pages('title_li=&depth=1&exclude=' . $exclude);
?>
share|improve this answer
    
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 '11 at 6:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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