Ready to get started?Download WordPress


tax_query limited from 3.6 to 3.7 (1 post)

  1. Adam Capriola
    Posted 5 months ago #

    I recently upgraded from 3.6 to 3.7 (and subsequently 3.7.1) and noticed on a database focused WordPress site I run that whenever I do an advanced search (via a customized form on the frontend) where I set a tax_query with more than two arguments, the search returns no results. Two or less arguments and results are returned as expected.

    I've ruled out any plugins effecting this (I disabled all of them) and I can't really test on a default theme since I've done heavy customization on my site with custom taxonomies and whatnot to allow the advanced searches on the frontend, but I also tested locally on my computer, and as soon as I upgraded to 3.7 the searches with more than two tax_query arguments stopped working. The functionality worked fine through 3.6.

    And to clarify, by more than two tax_query arguments I mean something like this:

    add_filter( 'pre_get_posts', 'ac_filter_search' );
    function ac_filter_search( $query ) {
    	// Argument 1
    	$tax_query[] = array(
    		'taxonomy' => 'tax1',
    		'field' => 'slug',
    		'terms' => 'term1',
    		'operator' => 'IN'
    	// Argument 2
    	$tax_query[] = array(
    		'taxonomy' => 'tax2',
    		'field' => 'slug',
    		'terms' => 'term2',
    		'operator' => 'IN'
    	// Argument 3
    	$tax_query[] = array(
    		'taxonomy' => 'tax3',
    		'field' => 'slug',
    		'terms' => 'term3',
    		'operator' => 'IN'
    	$query->set( 'tax_query', $tax_query );
    	return $query;

    I know the way search results are returned was altered in 3.7 to show more relevant results, but why would something fairly simple like this be affected?

    Here are the actual var_exported $query variables for a working search and a broken one (the only differences are in tax_query).

    Working: https://gist.github.com/adamcapriola/b7ae3b22e7f99e8bb3ee
    Broken: https://gist.github.com/adamcapriola/cc549fc2d77a4d21b8cb

    And consequently, this three argument tax_query does returns its expected results for some reason (I am thinking because it only has two 'IN' operators and one 'NOT IN' – the non-working has three 'IN'): https://gist.github.com/adamcapriola/86e0d53fe60ae1bc25e5

    Any smart people out there have any idea what's going on?


You must log in to post.

About this Topic

  • RSS feed for this topic
  • Started 5 months ago by Adam Capriola
  • This topic is not resolved
  • WordPress version: 3.7.1