Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a taxonomy query doesn't set the request type properly in WP_Query #12

Merged
merged 3 commits into from Nov 8, 2022

Conversation

mwidmann
Copy link

@mwidmann mwidmann commented Jun 4, 2019

When using a taxQuery in a query, the taxonomy relevant request type properties are not set correctly on WP_Query. So for example when querying a category $wp_query->is_category returns false even though it should be true. Or when combining a tag and category related query, e.g.

query THE_POSTS {
  posts(
    first: 10
    where: {
      taxQuery: {
        relation: OR,
        taxArray: [
          { taxonomy: CATEGORY, field: SLUG, terms: ["startseite", "kultur"] }
          { taxonomy: TAG, field: SLUG, terms: "bangladesch" }
        ]
      }
    }
  ) {
    pageInfo {
      hasNextPage
      endCursor
    }
    nodes {
      title
      postId
    }
  }
}

both $wp_query->is_tag and $wp_query->is_category should be true.

This was caused because the the taxonomy queries were nested inside an additional array in map_input_fields which caused the functionality in https://github.com/WordPress/WordPress/blob/32d761ce7dc8429f07469fde36e96830edca48f1/wp-includes/class-wp-query.php#L885 not to trigger.

The query worked fine though, but plugins relating on the request type failed.

@jasonbahl jasonbahl merged commit ffe711c into wp-graphql:master Nov 8, 2022
@jasonbahl jasonbahl mentioned this pull request Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants