I have one not resolved problem. There is one way to get posts within one term of taxonomy:
$args = array(
'tax_query' => array(
array(
'taxonomy' => 'person',
'field' => 'slug',
'terms' => 'bob'
)
)
);
$query = new WP_Query( $args );
But if I don't know any term of this taxonomy ('person')? I want to get posts that have taxonomy 'person' and any term either 'bob' or 'jim' or somebody else.
Code below is not working.
$args = array(
'tax_query' => array(
array(
'taxonomy' => 'person'
)
)
);
$query = new WP_Query( $args );
I don't know it is real or not to get posts in that way. I have an idea to get all terms of that taxonome and then get all posts. But maybe more elegant decision exists. Advise me corect code to do it. Thanks!