I’ve a customized publish sort known as ‘episode’. Hooked up to ‘episode’ I’ve a customized taxonomy known as ‘video_type’ that comprises two phrases: “bonus-footage” and “episode”; “episode” comprises two baby phrases “season-1” and “season-2” (different seasons will likely be added sooner or later). I need to seize solely the newest publish of the ‘episode’ sort however not embrace any posts from the ‘bonus-footage’ time period. Beneath is the code I am utilizing for this:
<?php
$some_args = array(
'tax_query' => array(
'taxonomy' => 'video_type',
'phrases' => 'bonus-footage',
'area' => 'slug',
'include_children' => true,
'operator' => 'NOT IN'
),
'posts_per_page' => 1,
'post_type' => 'episode',
);
$s = new WP_Query( $some_args );
if ( $s->have_posts() ) : $s->the_post();
// Do one thing with this publish.
endif;
?>
The question works as anticipated if a publish in one of many ‘season’ phrases is the most recent, but when a publish in “bonus-footage” is the most recent, then it is loading that one. In different phrases my “tax_query” parameters seem to haven’t any have an effect on on the question. Am I not formatting the “tax_query” correctly or am I lacking one thing else?
I’ve additionally tried setting “tax_query” as beneath:
'tax_query' => array(
'taxonomy' => 'video_type',
'phrases' => 'episode',
'area' => 'slug',
'include_children' => true,
'operator' => 'IN'
),
however I am nonetheless getting the identical end result.