WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a site that is in two distinct halves. I'd like the same template to apply to the whole site (from a look & feel perspective), but for each 'half' of the site to have its own top nav menu. No side menus are in use.

The home page is going to be a custom page that directs the user to one or other of the two sides.

How might I go about achieving this?

Many thanks


share|improve this question

The easiest solution would be to set a cookie. Then check what cookie the user have before you print the menu.

Another solution would be to add a query variable so that the two halves have different urls, for example mysite.com/?half=A and mysite.com/?half=B. Then you check the query var before you print the menu. This solution would make it possible with permalinks for the two different halves. (and you can make the urls pretty if you want)

share|improve this answer
Thanks Offroff - Travis' suggestion might fit the bill for me on this problem. Thanks for taking the time. Austen – Austen Osborne Apr 22 '12 at 16:28

Use a custom menu with wp_nav_menu(). Then check whether you're on part one or part two:

if ( ! is_home() || is_front_page() )
    $args = array(); // Define your menu here
    $query_string = explode( '/', $_SERVER['REQUEST_URI'] );

    // You need to var_dump( $query_string ); 
    // to see which index/key is matching your requested query string part
    if ( 'PART_ONE' === $query_string[0] )
        wp_nav_menu( array_merge( $args, array( 'menu' => 'MENU PART ONE' ) ) );
        wp_nav_menu( array_merge( $args, array( 'menu' => 'MENU PART TWO' ) ) );
share|improve this answer
Thanks Kaiser. I'll give Travis' idea a run, and refer back to this if it doesn't fit the bill. Austen – Austen Osborne Apr 22 '12 at 16:28

I believe the simplest solution would be to create two nav menus in the Wordpress backend, then load different headers based upon the page the visitor is on.

Start by copying your header.php 2 times, giving your three header files. Example: header.php, headerA.php, headerB.php

Now, open you original header.php and replace all the code with something like this:

if (is_page('contact')){
    <?php include(TEMPLATEPATH.'/headerA.php'); ?>
elseif (is_page('gallery')){
    <?php include(TEMPLATEPATH.'/headerB.php'); ?>
else {
    <?php include(TEMPLATEPATH.'/headerA.php'); ?>

This will tell Wordress which header to load, based on the type of page the visitor is on.

Also, make sure you load the correct menu in each header file using:

<?php wp_nav_menu( array('menu' => 'Menu A )); ?>
share|improve this answer
Thanks Travis - I like the sound of this idea. I'll give it a try. Austen. – Austen Osborne Apr 22 '12 at 16:27
This would be a lot easier to manage by just putting the two navigation menus inside the conditional rather than maintaining multiple header.php files. If page is ... Menu a, else menu b. – Christopher Apr 23 '12 at 3:30
+1 on the comment Christopher. That is simpler if the nav menu is the only thing changed between the different headers. – Travis Pflanz Apr 23 '12 at 3:32

Your Answer


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.