Let’s say you have 5 instances:
200, 201, 202, 203, 204
NOT IN {200, 201, 202} is equal to IN {203, 204} (all the other instances).
So you don’t need your IN operator anymore because its results are already included from using the NOT IN operator.
In your case, this logic works assuming an article does not have multiple locations.
$query->set('tax_query',
array(
array (
'taxonomy' => 'location',
'operator' => 'NOT IN',
'field' => 'slug',
'terms' => $notavailableRegions,
)
)
);
Related Posts:
- Why is my WP_Query not working when tax_query terms are an array?
- How to add terms to my tax_query based off of the current post
- Is it possible to dynamically get queried term AND taxonomy?
- Formulate a url to show posts with both taxonomy terms
- WP_Query tax query part of slug
- Taxonomy Query Relation field not behaving correctly?
- Get posts in taxonomy randomly
- Loop posts based on permalink term
- Show multiple tax_query from 2 or more post_type in a single code
- WP Query should show No Posts when tax_query $args taxonomies don’t have associated posts
- wp_query with meta_query and tax_query
- list all post who have mutual taxonomy as current taxonomy!
- Taxonomy archive, categorised by other taxonomy, not hiding empty taxonomies
- How can I get all the posts that are related with a specific taxonomy term?
- Empty ‘terms’ in ‘tax_query’ returns an empty array
- Get the tax term in which is a post via wp_query
- Custom query for certain post type OR another post type with a certain category
- Nested meta_query with multiple relation keys
- Escaping WP_Query tax_query when term has special character(s)
- Tax_query terms ID’s using variable
- Display posts the match taxonomy term linked from wp_list_categoies?
- SQL Statement generated by WP_Query not producing expected results
- Move posts to top of WP_Query if in certain Taxonomy?
- Querying Multiple Custom Taxonomy Terms
- How to combine tax_query and date_query in WordPress
- Querying by taxonomy vs Querying by Custom fields Speed Comparison
- How to extend tag and category “Related Posts” query to custom post_type if the first 2 terms have no posts
- Using tax_query reverses my post_type argument in a custom WP_Query
- WP Query – Get WooCommerce Products with variation that is in stock
- tax_query shows no results if nothing is selected
- Filter WordPress posts by between parameter
- get complex results set according to category structure
- How to Modify Taxonomy Archive Page with Search Parameter?
- WP_Query tax_query problem
- Query all posts in a given taxonomy
- Change default ordering of taxonomy terms – pre_get_terms
- WP_Query, tax_query and term_meta: How to?
- Order taxonomy terms in alphabetical order
- WP Query for variable taxonomies
- Empty tax_query array returns an empty array
- How can i simulate “taxonomy__in” in query?
- How do I search inside specific taxonomies in WordPress
- Meta Query relation “AND” not working
- Complex WP_Query (two post types and multiple operators)
- Populate tax_query terms parameter with post term
- Remove category from query (show all posts in archive.php) pre_get_posts()
- Fastest way of counting posts of a custom post type in a specific taxonomy term?
- Is it a good idea to improve meta query performance by adding tax query?
- WP_Query | Tax_Query Relation | Unable to use ‘OR’ as it then allows all products, help me finish my query?
- WP Query Args – Title or Taxonomy Value
- How to Union two different conditions in one WP_Query
- Slow queries on a huge database
- Tax query AND/OR meta query [duplicate]
- How do I exclude the lowest level terms in a taxonomy?
- How do I display the grand child items of a taxonomy term?
- Search Query for multiple categories using ‘OR’ but having certain categories be ‘AND’
- wp_query args adding muitiple tax_querys
- Automatically Query Parent Taxonomy
- How Can I Change The Tax Query For The Main Loop For Taxonomy Archives?
- Custom taxonomy.php not working
- WP_Query for a taxonomy with different taxonomy types
- Finding WordPress Posts assigned to multiple categories
- How to Order a list of taxonomies? orderby?
- How to add custom meta to ‘pre_get_terms’?
- WP Job Manager plugin – Listing only the twelve job categories on frontpage order by jobs they have
- How to print term name inside wp post loop
- How to search for meta_query LIKE or tax_query LIKE and grab these posts on search results?
- Function using get_posts() with tax_query not working when called from functions.php
- Running a custom query inside another cpt single and trying to grab a variable
- Don’t repeat posts from children in parent taxonomy query
- Tax_Query using WP_Query not working
- Custom taxonomy in WP_Query not working
- How to make a post with certain taxonomy term display first before other post with only one query?
- Any quicker alternative for WP_Query “NOT IN”
- Tax Query on product_cat using NOT IN as operator does not exclude that category
- How do I compare the value of two taxonomies in a wp_query
- How can I order a post query’s results based on the number of matching taxonomy terms?
- Only show tag with the same id as the post
- How to use the Term Object from a custom select field in a query
- WP_Query for a taxonomy value OR a custom post type meta field
- WP Query by 4 different taxonomies
- Select multiple categories with is_tax
- Why pagination is not working with tax_query param?
- Query child posts with tax query on parents
- How to break up output of posts for different terms on same page?
- pages shortcode filtering by category
- How to show terms from another taxonomy
- Combine Tax Archive and Meta_Query in WP_Query
- In Product Category archives how to show Posts having same/similar prod_cat slug structure?
- Category Archive not working for pages
- How to combine nested tax_query logic with other nested query logic?
- Escaping WP_Query tax_query when term has special character(s)
- Custom query for tag and custom tag from 2 post type
- Search format not matching taxonomy query
- List posts of terms but exclude one term
- Query multiple taxonomies with pagination
- Output ACF field dynamicaly within a taxonomy loop [closed]
- Multiple Orderby is not working right
- How can I get taxonomy term name using term slug & post ID using build in WordPress function or class?
- Custom query with custom filtering returning incorrect results