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
- Conditional arguments for WP_Query and tax_query depending on if $somevar has a value
- WP query taxonomy input differs to output?
- Does tax_query really beats meta_query in all situations?
- Get list of posts which have at least one term from a custom taxonomy with WP_Query
- if wp_query taxonomy term have posts
- Get random terms
- 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?
- List all custom post type posts from a given category?
- WP_Tax_Query with post_tag not working
- Display link to taxonomy archive only if it has posts with certain custom field values
- tax_query OR with empty result returns all posts
- tax_query returning all posts instead of selective posts in WP_Query
- Tax query clause inside a meta query clause?
- is_tax() function not working as expected
- Fetch posts that match term slug first two letters (wp query)
- How to order posts by title after they have already been sorted by category
- Post loop for all taxonomy terms
- Taxonomy and Date in same query?
- Query with meta_query and tax_query together not working properly
- Adding a tax_query to a WP_Query Object
- Order or Orderby in tax_query (How to define order of terms in WP_Query)
- Using custom taxonomies in a query
- Count posts per taxonomy else change taxonomy if less than x number
- get term id from term name
- Get Child Category only
- How to add tax_query to $args with concatenation
- How to echo woocommerce category name
- Avoid WP_Query’s duplicate posts with taxonomies
- Exclude post with taxonomy and from the terms (taxonomy & tag) posts count
- Use get_cat_ID to retreive multiple category IDs
- Get categories within specific term
- WP_Query paginate with one term per page?
- How to display Woocommerce products list by tag
- WordPress tax_query ignoring relation OR
- Optimal way to make tags in tax_query optional?
- in tax_query this Is the code correct? I need to access beginner video posts for different subject
- Taxonomy Terms That Don’t Exist Display Results
- display all posts from category with and without terms in chronological order
- WP Query with sticky posts and tax_query
- Extending WP Query: Custom geolocation meta values work, but tax_query breaks
- Multiple tax_queries: display posts titles from several custom taxonomie
- Escaping WP_Query tax_query when term has special character(s)
- How to get hierarchical number of custom taxanomy
- Add a custom variable to query page object
- How to use tax_query other than by slug or id or solve custom taxonomy tags conflicts with pre-existing tags?
- Advanced AND tax_query in sidebar with 2 taxonomies
- tax_query not working properly with get_posts
- WP_Query with tax_query not working
- query only direct child and sub-terms of a current term archive
- Get access to all terms associated to each post that the wp_query loop displays
- 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
- Include custom post type that matches taxonomy field in another custom post type
- Showing all posts of the current custom taxonomy on archive page