• Resolved thatstevensguy

    (@thatstevensguy)


    I understand what I am doing is weird. But I know I am not the only person out there doing this. I also should add that this was not a problem until WordPress 4.2.

    We use pre_get_posts hook to filter what is shown on the base query, using a custom taxonomy. This allows us to direct users to different subdomains and show alternate posts per subdomain. Recently I created a custom post type for a plugin, it also shares this base query custom taxonomy rule and one for its own purposes. This way I can filter by ‘area’ then by ‘category’.

    When I navigate to a term in the new custom taxonomy of the custom post type on the front end, I see the correct filtered output. The posts I am expecting to see. However the meta in the template head, and the template itself, is showing as if it were from the taxonomy applied to the base query. I am quite confused.

    It is as if the template is basing itself on the tax_query, but the post output is the correctly filtered output. Has anyone bumped into this before? What I want is for it to correctly show the template for the taxonomy I am viewing, not the tax_query.

    array (size=66)
      'bw_category' => string 'uncategorized' (length=13)
      'error' => string '' (length=0)
      'm' => string '' (length=0)
      'p' => int 0
      'post_parent' => string '' (length=0)
      'subpost' => string '' (length=0)
      'subpost_id' => string '' (length=0)
      'attachment' => string '' (length=0)
      'attachment_id' => int 0
      'name' => string '' (length=0)
      'static' => string '' (length=0)
      'pagename' => string '' (length=0)
      'page_id' => int 0
      'second' => string '' (length=0)
      'minute' => string '' (length=0)
      'hour' => string '' (length=0)
      'day' => int 0
      'monthnum' => int 0
      'year' => int 0
      'w' => int 0
      'category_name' => string '' (length=0)
      'tag' => string '' (length=0)
      'cat' => string '' (length=0)
      'tag_id' => string '' (length=0)
      'author' => string '' (length=0)
      'author_name' => string '' (length=0)
      'feed' => string '' (length=0)
      'tb' => string '' (length=0)
      'paged' => int 0
      'comments_popup' => string '' (length=0)
      'meta_key' => string '' (length=0)
      'meta_value' => string '' (length=0)
      'preview' => string '' (length=0)
      's' => string '' (length=0)
      'sentence' => string '' (length=0)
      'fields' => string '' (length=0)
      'menu_order' => string '' (length=0)
      'category__in' =>
        array (size=0)
          empty
      'category__not_in' =>
        array (size=0)
          empty
      'category__and' =>
        array (size=0)
          empty
      'post__in' =>
        array (size=0)
          empty
      'post__not_in' =>
        array (size=0)
          empty
      'tag__in' =>
        array (size=0)
          empty
      'tag__not_in' =>
        array (size=0)
          empty
      'tag__and' =>
        array (size=0)
          empty
      'tag_slug__in' =>
        array (size=0)
          empty
      'tag_slug__and' =>
        array (size=0)
          empty
      'post_parent__in' =>
        array (size=0)
          empty
      'post_parent__not_in' =>
        array (size=0)
          empty
      'author__in' =>
        array (size=0)
          empty
      'author__not_in' =>
        array (size=0)
          empty
      'meta_query' =>
        array (size=0)
          empty
      'tax_query' =>
        array (size=2)
          'relation' => string 'AND' (length=3)
          0 =>
            array (size=5)
              'taxonomy' => string 'n_area' (length=9)
              'field' => string 'slug' (length=4)
              'include_children' => boolean false
              'terms' =>
                array (size=2)
                  ...
              'operator' => string 'IN' (length=2)
      'ignore_sticky_posts' => boolean false
      'suppress_filters' => boolean false
      'cache_results' => boolean true
      'update_post_term_cache' => boolean true
      'update_post_meta_cache' => boolean true
      'post_type' => string '' (length=0)
      'posts_per_page' => int 10
      'nopaging' => boolean false
      'comments_per_page' => string '200' (length=3)
      'no_found_rows' => boolean false
      'taxonomy' => string 'bw_category' (length=18)
      'term' => string 'uncategorized' (length=13)
      'order' => string 'DESC' (length=4)
Viewing 1 replies (of 1 total)
  • Thread Starter thatstevensguy

    (@thatstevensguy)

    With the help of a friend looking at the queries with me, we figured it out. You have to firstly grab the tax_query, then apply the area query after the taxonomy query. So that the template and WordPress shows the correct information.

Viewing 1 replies (of 1 total)
  • The topic ‘tax_query on base query, causes template confusion’ is closed to new replies.