wp-graphql-tax-query icon indicating copy to clipboard operation
wp-graphql-tax-query copied to clipboard

Missing Nested taxonomy query support

Open vinny17690 opened this issue 4 years ago • 0 comments

Hi @jasonbahl, Just wondering, does this plugin support nested tax queries (added example code below)? I have tried, but couldn't make it work. Looks like taxQuery is limited to only one relation field and one taxArray. Ideally, taxArray should accept the nested taxArray fields right?

Are there any plans to support it, i think it's very crucial to be able to narrow down results to exactly what we want instead of fetching all the data, and process on the frontend.

How do we write below query in WPGraphQL? Any help would be great. Thanks!

'tax_query' => array(
    'relation' => 'AND',
    array(
        'taxonomy' => 'post_tag',
        'terms' => array( 'gum', 'cereal', 'candy' ),
        'field' => 'slug',
        'operator' => 'IN',     
    )
    array(
        'relation' => 'OR',
        array(
            'taxonomy' => 'favorite_turtle',
            'terms' => array( 'Raphael' ),
            'field' => 'name',
            'operator' => 'NOT IN',
        ),
        array(
            'taxonomy' => 'favorite_soda',
            'terms' => array( 'RC' ),
            'field' => 'name',
        ),
    ),
),

vinny17690 avatar Feb 10 '21 16:02 vinny17690