Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wrong wp_nav_menu displayed

Tags:

wordpress

my url looks like this: http://domain.com/?s=searchquery&post_type=qa_faqs

that page lists search results for "searchquery".

i then get the post type with

$post_type = $_GET['post_type'];

it echoes correctly

echo $post_type;
// Provides: qa_faqs

i then do an if/else to display a different menu via wp_nav_menu when $post_type is qa_faqs.

if ( $post_type == 'qa_faqs' ) {
  echo 'we got qa_faqs over here';
  wp_nav_menu(array('menu' => 'meta_menu', 'items_wrap' => '<dl id="%1$s" class="nice tabs vertical %2$s">%3$s</dl>', 'walker' => new sidenav_walker ));
} else {
  echo 'no qa_faqs in da house';
  wp_nav_menu(array('menu' => 'service_menu', 'items_wrap' => '<dl id="%1$s" class="nice tabs vertical %2$s">%3$s</dl>', 'walker' => new sidenav_walker ));
}

now to the funny part:

even though the page echoes 'we got qa_faqs over here', it displays the service_menu.

why´s that?

like image 507
joko13 Avatar asked Oct 12 '12 08:10

joko13


2 Answers

Found it - http://codex.wordpress.org/Navigation_Menus

Same problem was driving me nuts aswell.

Use 'theme_location' instead of 'menu' to point to which menu you want to output.

like image 134
Neros Avatar answered Sep 20 '22 17:09

Neros


Try targetting the specific menu with something like:

<?php wp_nav_menu( array('menu' => 'Your Menu Name' )); ?>
like image 44
SMacFadyen Avatar answered Sep 19 '22 17:09

SMacFadyen