• Hi there,

    I’ve been tearing my hair out a little trying to get tax_query working in my WP_Query. The code is as follows:

    $nextSundayTalkArgs = array(
    	'post_type' => 'talk',
    	'posts_per_page' => 1,
    	'tax_query' => array(
     		array(
      			'taxonomy' => 'talk-type',
      			'field' => 'slug',
      			'terms' => 'sunday-talk'
     		)
    	)
    );
    $nextSundayTalkQuery = new WP_Query( $nextSundayTalkArgs );

    There are definitely posts with the post type of “talk” – if I remove the tax_query part, the correct posts display just fine. There are 5 talks with the correct taxonomy term of “sunday-talk” (and it doesn’t work if I try to use IDs instead of slugs, either).

    Bizarrely, if I change the post type to “post” and the taxonomy to “category”, and leave out the “field” and “terms” part, it comes back with my only post to have no terms on it at all.

    Any help greatly appreciated, before I go insane.

Viewing 1 replies (of 1 total)
  • Thread Starter petegale

    (@petegale)

    (Please feel free to move this thread if I’ve posted in the wrong support category)

Viewing 1 replies (of 1 total)
  • The topic ‘Tax_Query misbehaving in WP_Query’ is closed to new replies.