joko13
joko13

Reputation: 640

wrong wp_nav_menu displayed

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?

Upvotes: 15

Views: 9883

Answers (3)

Neros
Neros

Reputation: 1129

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.

Upvotes: 51

SMacFadyen
SMacFadyen

Reputation: 3165

Try targetting the specific menu with something like:

<?php wp_nav_menu( array('menu' => 'Your Menu Name' )); ?>

Upvotes: 5

Jeffrey Carandang
Jeffrey Carandang

Reputation: 408

I think you dont have any items on the meta_menu. Please create menu under Appearance section and assign it. :)

Upvotes: 0

Related Questions