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 use this filter to show content from all custom post types in tags archive page

function tagFilter($query) {
    $post_type = $_GET['type'];
    if (is_tag()){
        if (!$post_type) {
            $post_type = 'any';
        $query->set('post_type', $post_type);
    return $query;

but somehow it stops the wp_nav_menu function and navigation menus do not appear in tags archive pages. I can't figure out where is the conflict between the two.

Any ideas?

share|improve this question
up vote 2 down vote accepted


if (is_tag()){

will be true for any query on a tag archive page, including the query WordPress makes to load menu items.

You want to check if the current query is both the main query and tag query:

if ($query->is_main_query() && $query->is_tag()){
share|improve this answer

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.