I would like to display a different menu in the same theme_location depending on some condition. I'm wondering if this is possible and if so how?
I would like to avoid registering an additional theme_location, since it would actually just be placed in the same location and having two locations in the same spot might confuse the user.
I tried naming another menu in the first if statement, but I just got the same menu as in the else.
My code:
<?php
if ( preg_match ('#^/company/#', $_SERVER['REQUEST_URI']) ) {
# get me another menu in the same theme location as below
}
else {
wp_nav_menu( array( 'menu' => 'Primary Menu', 'theme_location' => 'primary' ) );
}
?>
Do I have to register two theme_locations or is this possible with one?