Tweeted twitter.com/#!/StackWordPress/status/456684870538780672
2 added 207 characters in body
source | link

I have a page on my site that acts as a search tool/search results page for users to find rental spaces. On the left side is a column of checkboxes that let the user filter the results by three separate custom taxonomies (space-types, space-features, space-areas) the right side of the page lists the results after the checkbox form is submitted.

I am trying to properly query the spaces (custom post type space-listings) based on the selected terms in each taxonomy but the logic doesn't seem to be possible and I'm not sure how else to do it.

This is the needed logic: If the space listing has ALLANY of the space-types ANDand ALL of the space-features that the user has selected AND also has at least ONEANY of the space-areas that they have selected.

Here is the closest I've gotten with my query array:

$searchspace = array (
'post_type'=>'space_listing',
'posts_per_page'=> 3,
'paged' => $paged,
'tax_query'=> array (
    'relation' => 'AND',
    array (
        'taxonomy' => 'space-areas'types',
        'field' => $searchedareas'slug', 
 //$searchedareas is an array of areas  'terms' => $searchedtypes, //Array of selected types
'tax_query'=> array (
    'relation'              'operator' => 'AND''IN'//default
        ),
    array (
        'taxonomy' => 'space-types'features',
        'field' => 'slug',
        'terms' => $searchedtypes$searchedfeatures, //Array of selected typesfeatures
                    'operator' => 'AND'
        ),
            array (
                    'taxonomy' => 'space-features'areas',
        'field' => 'slug',
        'terms' => $searchedfeatures$searchedareas, //Array of selected featuresareas
                    'operator' => 'IN'//default
        ),
    )

);

I have a page on my site that acts as a search tool/search results page for users to find rental spaces. On the left side is a column of checkboxes that let the user filter the results by three separate custom taxonomies (space-types, space-features, space-areas) the right side of the page lists the results after the checkbox form is submitted.

I am trying to properly query the spaces (custom post type space-listings) based on the selected terms in each taxonomy but the logic doesn't seem to be possible and I'm not sure how else to do it.

This is the needed logic: If the space listing has ALL of the space-types AND space-features that the user has selected AND also has at least ONE of the space-areas that they have selected.

Here is the closest I've gotten with my query array:

$searchspace = array (
'post_type'=>'space_listing',
'posts_per_page'=> 3,
'paged' => $paged,
'space-areas' => $searchedareas, //$searchedareas is an array of areas selected
'tax_query'=> array (
    'relation' => 'AND',
    array (
        'taxonomy' => 'space-types',
        'field' => 'slug',
        'terms' => $searchedtypes, //Array of selected types
        ),
    array (
        'taxonomy' => 'space-features',
        'field' => 'slug',
        'terms' => $searchedfeatures, //Array of selected features
        ),
    )

);

I have a page on my site that acts as a search tool/search results page for users to find rental spaces. On the left side is a column of checkboxes that let the user filter the results by three separate custom taxonomies (space-types, space-features, space-areas) the right side of the page lists the results after the checkbox form is submitted.

I am trying to properly query the spaces (custom post type space-listings) based on the selected terms in each taxonomy but the logic doesn't seem to be possible and I'm not sure how else to do it.

This is the needed logic: If the space listing has ANY of the space-types and ALL of the space-features that the user has selected AND has ANY of the space-areas that they have selected.

Here is the closest I've gotten with my query array:

$searchspace = array (
'post_type'=>'space_listing',
'posts_per_page'=> 3,
'paged' => $paged,
'tax_query'=> array (
    'relation' => 'AND',
    array (
        'taxonomy' => 'space-types',
        'field' => 'slug', 
        'terms' => $searchedtypes, //Array of selected types
                    'operator' => 'IN'//default
        ),
    array (
        'taxonomy' => 'space-features',
        'field' => 'slug',
        'terms' => $searchedfeatures, //Array of selected features
                    'operator' => 'AND'
        ),
            array (
                    'taxonomy' => 'space-areas',
        'field' => 'slug',
        'terms' => $searchedareas, //Array of selected areas
                    'operator' => 'IN'//default
        ),
    )

);
1
source | link

Advanced Query Logic With Multiple Taxonomies

I have a page on my site that acts as a search tool/search results page for users to find rental spaces. On the left side is a column of checkboxes that let the user filter the results by three separate custom taxonomies (space-types, space-features, space-areas) the right side of the page lists the results after the checkbox form is submitted.

I am trying to properly query the spaces (custom post type space-listings) based on the selected terms in each taxonomy but the logic doesn't seem to be possible and I'm not sure how else to do it.

This is the needed logic: If the space listing has ALL of the space-types AND space-features that the user has selected AND also has at least ONE of the space-areas that they have selected.

Here is the closest I've gotten with my query array:

$searchspace = array (
'post_type'=>'space_listing',
'posts_per_page'=> 3,
'paged' => $paged,
'space-areas' => $searchedareas, //$searchedareas is an array of areas selected
'tax_query'=> array (
    'relation' => 'AND',
    array (
        'taxonomy' => 'space-types',
        'field' => 'slug',
        'terms' => $searchedtypes, //Array of selected types
        ),
    array (
        'taxonomy' => 'space-features',
        'field' => 'slug',
        'terms' => $searchedfeatures, //Array of selected features
        ),
    )

);