The problem is ambiguity, you can’t just put in 'relation' => 'OR'
in the main parameter list, because how would WP_Query
know if it’s for the tax_query
and not the meta_query
?
For how it’s supposed to work, and where the relation
parameter goes we need to refer to the official docs for WP_Query
which gives us this example:
$args = array(
'post_type' => 'post',
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => array( 'quotes' ),
),
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array( 'post-format-quote' ),
),
),
);
$query = new WP_Query( $args );
Setting it may be as simple as:
$myarray['relation'] = 'OR'; // untested
Related Posts:
- How to add custom meta to ‘pre_get_terms’?
- How to show terms from another taxonomy
- 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?
- Empty tax_query array returns an empty array
- How do I search inside specific taxonomies in WordPress
- 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
- Return Taxonomy/Term Information with Posts (WP_Query/get_posts)
- Get authors by term id or slug
- Slow queries on a huge database
- Taxonomy order exception for specific term
- Get posts from multiple tax terms
- How to Order a list of taxonomies? orderby?
- WP Job Manager plugin – Listing only the twelve job categories on frontpage order by jobs they have
- 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?
- Only show tag with the same id as the post
- Save queried result into database
- taxquery taxonomy get terms
- How to define a custom hierarchy for terms?
- How can I get all the posts that are related with a specific taxonomy term?
- How to get several fields from wp_query?
- Displaying Results From Custom Taxonomy Query
- How can I get taxonomy term name using term slug & post ID using build in WordPress function or class?
- Modify WordPress Search
- Need help with Query Loop. Need to get current taxonomy term and its posts and group them by a different selected taxonomy term
- Notice thrown when creating numeric pagination on custom query
- wordpress udpate query not equal to
- WP Query – filtering terms with regex
- Is it possible to retrieve posts depending on meta_key LIKE condition? [duplicate]
- Write WP Query that selects posts that are part of the same two categories
- How to get posts by category and by choosing a taxonomy term?
- WP_User_Query orderby meta_val_num
- WP_Query custom order and pagination
- relation OR instead of AND – Filtered term ID’s in loop
- How to SQL query posts IDs by categories AND authors?
- Unable to paginate a custom page query
- Using in ‘category_name’ in ‘$query->set();’?
- Include one page/post into query which is already returning posts
- I am officially missing something about transient posts
- Insert images into wordpress post with a query
- Don’t repeat posts from children in parent taxonomy query
- Why doesn’t my WP Meta Query return any results?
- WP_Query meta compare must include ALL array values
- Start Query from 2nd Post without offset
- Show multiple tax_query from 2 or more post_type in a single code
- How can I query all post with currrent taxonomy term?
- Disable (or limit) queries when certain content (or data) is not needed (or showed)
- How to get the term description in a taxonomy term archive query?
- Avoid WP_Query’s duplicate posts with taxonomies
- Deleting terms from the WordPress wp terms table
- Custom taxonomy in WP_Query not working
- Retrieve all term IDs of post
- Display upcoming events in the next 30 days by querying posts with timestamp in custom meta
- Prioritising and Ordering Posts By Category Name Using A Custom Loop
- meta_query where the meta value is not the post title
- get_the_terms has strange result since version 6.0
- How can I do a orderby by the number of items? So basically list by starting with the array with the largest number of post
- Post incorrectly excluded when using “category__in”?
- Query multiple post types, but different order for each
- Exclude post with taxonomy and from the terms (taxonomy & tag) posts count
- Multi-layered WP_Query
- `offset` WP_Query argument dont work via `pre_get_posts`
- Use get_cat_ID to retreive multiple category IDs
- Filter products on category AND tag
- Display posts ONLY from the current logged in user and current week/year/month Elementor posts
- Strange behaviour of hierarchical taxonomy archive
- Pagination of custom page with custom fields query
- Query pages created by deleted users
- WP Query should show No Posts when tax_query $args taxonomies don’t have associated posts
- display ACF repater field in archive page
- tax_query not working on custom post type
- How to use the Term Object from a custom select field in a query
- setting offset to category number in archive page
- Woocommerce Get Orders By Meta Value
- Any way to use FETCH_KEY_PAIR with $wpdb?
- WP Query by 4 different taxonomies
- pre_user_query vs pre_get_posts
- Exclude post from wp_query based on custom field boolean
- WooCommerce WP_Query using tax_query returns no results (0 = 1)
- How to do WP_User_Query for Nested Array value Inside Nested Array field
- Display Custom Post Type Based on Taxonomy With WP_Query()
- Get posts that match defined arrays of tags
- wp_query with meta_query and tax_query
- Doing $wpdb->get_results returns NULL, doing the same query in my DB returns correct value
- Move some posts to end of sort order, even if there is a sort in the wp_Query already
- Get categories within specific term
- Adding nofollow to all the post links in get_posts with pre_get_posts or WP_Query
- WP_Query paginate with one term per page?
- Meta query orderby meta_value_num sorting by role first
- WordPress – Form does not filter the results of taxonomies
- How to get meta key list efficiently?
- WP_Query for custom taxonomies showing posts from non-specified terms?
- Order posts by tags count?
- Query against multiple locations within single custom post type post