Wordpress query with AND returns data as OR

I need to build WP_Query that will return data from database where both conditions are fulfilled, because of that I'm using AND as relation but returned data are different than I expected. To make it more clear I will post WP_Query arguments here.

Array(
[post_type] => Array
    (
        [0] => event
    )

[post_status] => publish
[paged] => 1
[posts_per_page] => 1000
[tax_query] => Array
    (
        [relation] => AND
        [1] => Array
            (
                [taxonomy] => event_dates
                [field] => slug
                [terms] => Array
                    (
                        [0] => thursday
                        [1] => exhibitions
                    )

            )

    )

)

With this arguments I thought that I'll get events with type exibition AND are on Thursday.

Thanks in advance for help.

Solutions

The AND is on the wrong level. The WP_Query arguments should look like something like this:

...
'tax_query' => array(
    array(
    'taxonomy' => 'event_dates',
    'field' => 'slug',
    'terms' => array('thursday', 'exhibitions'),
    'operator' => 'AND'
    )
)
...
Tags: Mysql / SQL / Wordpress

Similar questions

Meta Query Returns Nothing when Too Much Data
I am doing a "find dealer" lookup for a company so that users can put in a zip code and a radius and find all the dealers within that radius. It seems to work fine until I get a couple thousand zip codes. I am passing in the array of zip codes to a meta_query and checking that against my custom post type dealer with its key of zip to find all deale...
WP User Query & wp-admin/admin-ajax returns 0 with data
I have a odd problem and i'm hoping one of you could guide me to the answer. I am new to PHP and JQuery, so i'm not really sure what is causing this, but essentially, I have a ajax call for a custom search field that works. The "problem" is that after every search result it returns a very random '0' after the results. So for example if I ...
Use custom query if main search query returns zero results in wordpress
I have a search page where if the main search returns 0 results then the following query will be used. The code is Now I am getting an error which says "Not unique table/alias: 'wp_postmeta'" When I print the second query in browser it says, Is it like, I have to close the previous query and then run the custom query. Any help is highly appreciated...
which CSS query method is the best to use:container query.element query or media query?
I like to know which kind of queries I have to use because this is my first website I am developing and I am working with foundation grid system. I see at this moment you have containers queries which is more targeted to an element . also I see you have element queries and media queries. to have modern responsive website which one I have to use and...
Woocommerce ajax remove from cart and update cart data returns zero
I am trying to minus a product or remove a product from cart.Suppose i have 3 same item in cart and i want to minus one but the ajax i used not works.I returns zero on console log.I thing this zero is from wp die().But it is expected to return some data. But it returns only zero in console. In js passed variable hash,nonce,qty are okay. Got php cod...
How to query posts with certain custom meta data, and output Post data
I've been working on modifying the Thesography plugin to include the Google Maps API. So far I've had success doing so. I'm looking to take this one step further and have 1 large Google Map that would display all of my images on 1 map. Then when you hover over a marker, an image thumbnail comes up with the post title. I know the requirements for th...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.