This should be possible with the tax_query
parameters for WP_Query
.
The query is either for posts where any term NOT EXISTS
, OR
, for any posts where the term IDs are IN
the provided array.
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'group',
'operator' => 'NOT EXISTS',
),
array(
'taxonomy' => 'group',
'field' => 'term_id',
'terms' => array( 23, 42 ),
'operator' => 'IN',
),
)