When you’re doing a tax_query
or meta_query
in a WP_Query
, you always have to use a nested
array( array() );
just see the following example for an explanation and pay attention to the relation
argument.
$packages = new WP_Query( array(
'post_type' => 'vamos-cpt-packages',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'vamos-holiday-types',
'field' => 'slug',
'terms' => array( 'activity-holidays' )
),
array(
'taxonomy' => 'vamos-holiday-types',
'field' => 'id',
'terms' => array( 103, 115, 206 ),
'operator' => 'NOT IN'
)
)
) );
Related Posts:
- How to add terms to my tax_query based off of the current post
- WP Query for Posts (Products) in Specific Category that has 2 Specific Tags (*AND* both tags not *OR*)
- Change default ordering of taxonomy terms – pre_get_terms
- Is it possible to dynamically get queried term AND taxonomy?
- Empty tax_query array returns an empty array
- Pass array of taxonomy terms to wp_query
- Get list of terms that have posts in another term
- Formulate a url to show posts with both taxonomy terms
- Taxonomy search/filter with multiple taxonomies and multiple taxonomy terms
- Order by slug in get_terms with multiple taxonomies
- Function get_queried_object() return NULL in custom taxonomy
- Querying on multiple taxonomies pulled from $_GET checkbox array not working?
- Return Taxonomy/Term Information with Posts (WP_Query/get_posts)
- Get authors by term id or slug
- Custom post taxonomies as tax_query terms?
- WP_Query tax query part of slug
- Taxonomy Query Relation field not behaving correctly?
- Taxonomy order exception for specific term
- Get posts from multiple tax terms
- 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
- 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
- Can’t get term id for category archive
- How to make a post with certain taxonomy term display first before other post with only one query?
- How can I order a post query’s results based on the number of matching taxonomy terms?
- WP Query should show No Posts when tax_query $args taxonomies don’t have associated posts
- Only show tag with the same id as the post
- Save queried result into database
- wp_query with meta_query and tax_query
- taxquery taxonomy get terms
- How to show terms from another taxonomy
- How to define a custom hierarchy for terms?
- How can I get all the posts that are related with a specific taxonomy term?
- Custom taxonomy and query multi conditions
- 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
- How can I get taxonomy term name using term slug & post ID using build in WordPress function or class?
- Nested meta_query with multiple relation keys
- Multiple relationship for multiple tax_query in WP_Query
- Tax_query terms ID’s using variable
- Exclude posts that only have the ‘Uncategorized’ category [duplicate]
- get_terms with posts that have a different taxonomy with term x
- Adding a term name from a custom taxonomy assigned to a post link displayed by a wp_query loop based on another taxonomy
- Get random terms
- 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
- tax_query: What to pass when I want to have all terms?
- WP Query – Get WooCommerce Products with variation that is in stock
- WP_Tax_Query with post_tag not working
- Filter WordPress posts by between parameter
- How to Modify Taxonomy Archive Page with Search Parameter?
- Query all posts in a given taxonomy
- Display link to taxonomy archive only if it has posts with certain custom field values
- WP Query for variable taxonomies
- pre_get_posts Remove tax_query Completely
- Meta Query relation “AND” not working
- Getting Taxonomy inside WP_Query Loop
- Nested tax_query that allows specified categories OR tags, but NOT other categories
- Complex WP_Query (two post types and multiple operators)
- Remove category from query (show all posts in archive.php) pre_get_posts()
- Display Featured Post by Categories and Avoid duplicated posts
- Fetch posts that match term slug first two letters (wp query)
- How to Union two different conditions in one WP_Query
- Tax query AND/OR meta query [duplicate]
- How do I exclude the lowest level terms in a taxonomy?
- Post loop for all taxonomy terms
- Tax Query only returns for the first of several terms
- Getting the post terms ‘wp_get_post_terms’ per post when within the functions.php file
- Check if a post has term inside loop
- WP Query – filtering terms with regex
- How to get posts by category and by choosing a taxonomy term?
- How to restrict search on a certain page to only return results against custom taxonomies?
- 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
- Deleting terms from the WordPress wp terms table
- get_the_terms has strange result since version 6.0
- Strange behaviour of hierarchical taxonomy archive
- Display related CPT with custom taxonomy
- tax_query not working on custom post type
- WooCommerce WP_Query using tax_query returns no results (0 = 1)
- WordPress – Form does not filter the results of taxonomies
- Why pagination is not working with tax_query param?
- Show one post of each custom taxonomy
- Query child posts with tax query on parents
- How to break up output of posts for different terms on same page?
- posts_per_page in a tax_query
- Custom category page with taxonomy filters
- Woocommerce orderby rand with tax_query not random
- Escaping WP_Query tax_query when term has special character(s)
- How to get several fields from wp_query?
- Multiple Orderby is not working right
- taxonomy-{term}.php terms pagination returning 404 after a certain page
- Using WP Query, I want to include all posts in category 1 as long as they are not also in category 2