• Resolved jordas

    (@jordas)


    Hey,

    I was wondering if anybody nows an easy answer to the following:

    I am using a tax_query, but I want to customize it even further by only displaying from a specific category within that taxonomy. Maybe the code will explain clearer what I want:

    $args = array(
    	'post_type' => 'post',
    	'tax_query' => array(
    		'relation' => 'AND',
    		array(
    			'taxonomy' => 'movie_genre',
    			'field' => 'slug',
    			'terms' => array( 'action' ),
                            // here's what I want to add, only posts of a category within 'action'
                            'category__in' => some_given_cat_id
    		),
    		array(
    			'taxonomy' => 'actor',
    			'field' => 'id',
    			'terms' => array( 103, 115, 206 ),
    			'operator' => 'NOT IN'
    		)
    	)
    );
    $query = new WP_Query( $args );

    But the category__in simply gets ignored, and if I move it anywhere else my query displays empty.

    Where or how can I specify this filtering on the right category.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter jordas

    (@jordas)

    Nevermind…

    I am a fool,
    You can just replace the term with the child of that term and it will filter correctly. So if ‘action’ is divided up in ‘funny-action’ and ‘scary-action’, you can actually just use one of the latter two…

    Thread Starter jordas

    (@jordas)

    Meaning its resolved

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding a category__in to a tax_query’ is closed to new replies.