What you’re trying to do — using the OR
relation with the tax_query
and meta_query
parameters, i.e. to have a <tax queries> OR <meta queries>
instead of <tax queries> AND <meta queries>
command in SQL, unfortunately (without custom and possibly complex queries) is not possible in WP_Query
for now, therefore that 'relation' => 'OR'
in your query args (the $args
array) is not going to work or even do anything.
However, what you can (and I would) do, is: Turn that metadata into a custom taxonomy which is better suited for grouping a collection of posts together just like in your case where you used the metadata to group posts that are “playlist-available” (?), and moreover, taxonomy terms can also be as simple as 1
and 0
, and not necessarily need to be titles like Movies
and Web Design
. You could even create a custom metabox with a “Yes-or-No” checkbox which then updates the taxonomy terms for the post. (I mean, if you don’t like the default taxonomy UI/selector..)
So for example, register a taxonomy named playlist_available
, and then add these terms to that taxonomy: 1
(“Playlist available”) and 0
(“Playlist not available”) — although I think you may not need the latter..?
And then for all existing posts that had the metadata _csl_playlist_available_to_all
set to 1
, remove that metadata from the post and then assign the post to the 1
term in the playlist_available
taxonomy.
Then when you make your WP_Query
, there’s no need for the meta_query
and just add another clause to the tax_query
parameter/array:
$args = array(
'post_type' => 'csl_playlist_manager',
'tax_query' => array(
'relation' => 'OR',
array( // selects posts that are in this taxonomy
'taxonomy' => 'csl_source',
'field' => 'term_id',
'terms' => $strTax,
),
array( // OR the ones with the playlist available
'taxonomy' => 'playlist_available',
'field' => 'slug',
'terms' => '1', // or whatever the slug is
),
),
// ... your other args.
);
And now that should give you the results you expected, and the query would also run faster than with the meta_query
which could end up with various JOIN clauses — on small sites, you may not notice an obvious performance boost; but you would when your site gets larger (many posts, options, plugin data, traffic/users, etc.). But a bit of disclaimer, I’m far from being a performance expert. 🙂