My issue is pretty simple, I’m trying to get both portfolio posts (from a plugin) and articles that have the “portfolio” category (made myself).
$args = array(
'post_type' => 'portfolio',
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => 'portfolio',
)
)
);
$query = new WP_Query($args);
It looks like the relationship between post_type and tax_query is an AND, I’d need an OR, how can I do that?
I tried following the official documentation but I’m stuck. (https://codex.wordpress.org/Class_Reference/WP_Query)
Thanks for the help.
Here is an example with a relation ‘OR’:
I haven’t found any solution using only one query. (couldn’t change the
AND
toOR
).So I’ve made two queries instead:
It works correctly, even though it’s not what I’d like to use.