Created
June 20, 2016 14:26
-
-
Save SErr0r/624f8824728bc6ec0538403f878b1849 to your computer and use it in GitHub Desktop.
Filter by Taxonomy with AND/OR Relation between multiple taxonomies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$args = array( | |
'post_type' => 'post', | |
'tax_query' => array( | |
'relation' => 'AND', | |
array( | |
'taxonomy' => 'movie_genre', | |
'field' => 'slug', | |
'terms' => array( 'action', 'comedy' ) | |
), | |
array( | |
'taxonomy' => 'actor', | |
'field' => 'id', | |
'terms' => array( 103, 115, 206 ), | |
'operator' => 'NOT IN' | |
) | |
) | |
); | |
$query = new WP_Query( $args ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We shall even use 'operator' with values 'AND/OR/NOT/NOT IN' relation with in a taxonomy.