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
- Multiple relationship for multiple tax_query in WP_Query
- WordPress tax_query “and” operator not functioning as desired
- Conditional arguments for WP_Query and tax_query depending on if $somevar has a value
- WP query taxonomy input differs to output?
- Search custom taxonomy term by name
- Escaping WP_Query tax_query when term has special character(s)
- Does tax_query really beats meta_query in all situations?
- Tax_query terms ID’s using variable
- How to display post from current Taxonomy in archive page?
- Display posts the match taxonomy term linked from wp_list_categoies?
- Counting number of posts with Category B in Category A
- SQL Statement generated by WP_Query not producing expected results
- if wp_query taxonomy term have posts
- Move posts to top of WP_Query if in certain Taxonomy?
- WooCommerce: filter by parent product’s taxonomy and product variation’s meta data
- Querying Multiple Custom Taxonomy Terms
- How do I search WordPress by different fields without a plugin?
- 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 for Posts (Products) in Specific Category that has 2 Specific Tags (*AND* both tags not *OR*)
- Find all product that contain terms with %keywords% in WP_Query
- Get term by custom term meta and taxonomy
- Filter and list posts of a custom taxonomy
- WP Query – Get WooCommerce Products with variation that is in stock
- tax_query shows no results if nothing is selected
- WP_Tax_Query with post_tag not working
- 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
- Filtering posts by custom field value not working
- Query all posts in a given taxonomy
- Change default ordering of taxonomy terms – pre_get_terms
- Display link to taxonomy archive only if it has posts with certain custom field values
- tax_query OR with empty result returns all posts
- 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
- tax_query returning all posts instead of selective posts in WP_Query
- Pass array of taxonomy terms to wp_query
- Get list of terms that have posts in another term
- pre_get_posts Remove tax_query Completely
- tax_query: Order by slug?
- Taxonomy search/filter with multiple taxonomies and multiple taxonomy terms
- Order by slug in get_terms with multiple taxonomies
- Output an array of terms for a ‘tax_query’ => array()
- Meta Query relation “AND” not working
- Tax query clause inside a meta query clause?
- Function get_queried_object() return NULL in custom taxonomy
- Getting Taxonomy inside WP_Query Loop
- Nested tax_query that allows specified categories OR tags, but NOT other categories
- Querying on multiple taxonomies pulled from $_GET checkbox array not working?
- Complex WP_Query (two post types and multiple operators)
- WP_Query Not Recognizing Taxonomy Parameter in Custom Search
- Populate tax_query terms parameter with post term
- Return Taxonomy/Term Information with Posts (WP_Query/get_posts)
- Remove category from query (show all posts in archive.php) pre_get_posts()
- is_tax() function not working as expected
- Advanced Taxonomy Queries WordPress
- Fastest way of counting posts of a custom post type in a specific taxonomy term?
- Display Featured Post by Categories and Avoid duplicated posts
- Fetch posts that match term slug first two letters (wp query)
- Get authors by term id or slug
- Is it a good idea to improve meta query performance by adding tax query?
- Custom post taxonomies as tax_query terms?
- 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’
- Combining categories (Query posts with multiple taxonomy terms)
- Post loop for all taxonomy terms
- wp_query args adding muitiple tax_querys
- Taxonomy and Date in same query?