Last active
June 3, 2022 23:27
-
-
Save Tmeister/4096885f0b622d4031cd1afc6fb6c864 to your computer and use it in GitHub Desktop.
A simple sample to query two Custom Post Types with a tax_query
This file contains 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 = [ | |
'post_type' => ['post', 'work'], | |
'posts_per_page' => -1, | |
'tax_query' => [ | |
'relation' => 'OR', | |
[ | |
'taxonomy' => 'post_tag', | |
'field' => 'slug', | |
'terms' => 'tag-two' | |
], | |
[ | |
'taxonomy' => 'category', | |
'operator' => 'NOT EXISTS' | |
] | |
] | |
]; | |
$posts = new WP_Query($args); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment