I have a custom content type called media_player. I have a taxonomy for it called sermon_series.
Most of my singles have terms that are children of the term ‘sermons’
I’m trying to get the three most recent media_player items in that have or are children of the ‘sermons’ term.
The query I have is not getting the latest one, but rather 2-4. 2-4 have the same term, item 1 has a new one.
I narrowed it down some, using the newsest one specifically, so here’s my current query:
$args = array( 'post_type' => 'media_player' ,'post_status' => 'publish' ,'posts_per_page' => 3 ,'no_found_rows' => 1 ,'orderby' => 'date' ,'order' => 'desc' ,'tax_query' => array( array( 'taxonomy' => 'sermon_series', 'field' => 'name', 'terms' => array('the-resiliant-life'), ) ) );
This gets me NO results, even though the 1 latest item has the term ‘the-resiliant-life’.
I’ve verified that that one is published, not private, etc.
The SQL that gets sent with that query is
SELECT wpada_posts.ID FROM wpada_posts WHERE 1=1 AND 0 = 1 AND wpada_posts.post_type = 'media_player' AND ((wpada_posts.post_status = 'publish' OR wpada_posts.post_status = 'private')) GROUP BY wpada_posts.ID ORDER BY wpada_posts.post_date desc LIMIT 0, 3
Which you’ll note doesn’t have any term ids in it at all. Where am I going wrong?
- The topic ‘tax_query not getting what I expect’ is closed to new replies.