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?
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.
Try targetting the specific menu with something like:
<?php wp_nav_menu( array('menu' => 'Your Menu Name' )); ?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With