Skip to content

Search posts by custom taxonomy or AFC taxonomy #2237

Answered by albertcito
albertcito asked this question in Q&A
Discussion options

You must be logged in to vote

I found the solution. Just use this plugin:
https://github.com/wp-graphql/wp-graphql-tax-query

I have a post_type called books and a taxonomy call author. This is the query in order to get all

{
  books(
    where: {
      taxQuery: {
        taxArray: {
          taxonomy: AUTHORTAG, 
          operator: AND, 
          terms: "john-doe", 
          field: SLUG
        }
      }
    }
  ) {
    nodes {
      databaseId
      title
      authorTags {
        nodes {
          databaseId
          slug
        }
      }
    }
  }
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ShahriarKh
Comment options

Answer selected by albertcito
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants