You can achieve the OR relation using the tax_query
argument like so:
$query->set( 'tax_query', array(
'relation' => 'OR',
array(
'taxonomy' => 'category',
'terms' => array( 2, 3 ),
),
array(
'taxonomy' => 'post_tag',
'terms' => array( 10, 13 ),
),
) );
Related Posts:
- When to use WP_query(), query_posts() and pre_get_posts
- How-to exclude terms from the main query the most performant way?
- Is it possible to select against a post’s parent’s fields with WP_Query?
- Slow SQL_CALC_FOUND_ROWS Query
- SQL Statement generated by WP_Query not producing expected results
- SQL query equivalent to WP User Query
- Recommended way to drop a pending query (in pre_get_posts)?
- Can not switch the queried post in pre_get_posts hook
- SQL User Query by Multiple Roles using PHP
- SELECT * FROM $wpdb->posts WHERE ID > 160
- Single meta_query query using OR instead of AND in request’s WHERE statement
- Slow WP_Query for custom post type
- Complex WP SQL Query
- Help with WP_Query – Too many mySQL queries
- Order by summing multiple values
- SQL query injection with fifu image
- WP Query – grouping posts by same meta key, adding together values from another key
- Slow query when selecting with large meta query or post__in
- When to use WP_query(), query_posts() and pre_get_posts
- When should you use WP_Query vs query_posts() vs get_posts()?
- WP_Query with “post_title LIKE ‘something%'”?
- Should I use Pre Get Posts or WP_Query
- Using pre_get_posts with WP_Query
- Pagination with custom SQL query
- Return only Count from a wp_query request?
- Use REGEXP in WP_Query meta_query key
- WP_Query orderby post__in remains ineffective in the Loop [closed]
- How to use the_posts_navigation for wp_query and get_posts?
- WP_Query vs get_posts
- What is “main query”? [duplicate]
- Order by DESC, ASC in custom WP_Query
- How to prevent execution of default query, while preserving ability to use WP_Query in template?
- meta_query: using BETWEEN with floats and/or casting to DECIMAL
- Get posts from Network (Multisite)
- How to order by post_status?
- Using get_posts vs. WP_Query
- Whats the difference between post_limits and pre_get_posts?
- Delete all posts from WordPress except latest X posts
- Reduce or prevent calling of update_meta_cache
- How to add taxonomy filter on the query fly?
- Using OR conditions in meta_query for query_posts argument
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- Sanitation needed for WP_Query or get_posts calls?
- Differences Between WP_Query() and get_posts() for Querying Posts?
- How to uniquely identify queries?
- Get Recent Posts by Date in Multisite
- Is it possible to wrap Geo Location search around WP_Query?
- Order Search Results Page by meta_value If no Value Return Remaining Results
- Getting wrong relationship value in $args in wp_Query?
- get_posts with multiple categories
- get_template_part in for loop
- Use of caller_ get_ posts
- pre_get_posts with get_posts
- Get posts by menu ID
- Changing Posts Per Page and offset with pre_get_posts
- Query all posts where meta value is empty
- Extending WP_Query — Optimise SQL query
- “pre_get_posts” firing on every query
- RSS feed with specific keyword
- Get posts by meta data OR title
- Get_post() with meta_key when compare is a date
- How to filter sql only for a specific post type
- Using is_main_query to select custom post type on certain page
- get_posts not finding argument: post_name
- Meta Query with date and time on the same Day before given time
- Multiple orderby parameters in pre_get_posts() action
- How to make an activities stream mixing posts and comments?
- Get posts with condition on comment meta value
- What is an efficient way to query based on post_meta?
- Function to check if author has posted within the last x days
- What’s wrong with this WP query?
- Stop all SQL_CALC_FOUND_ROWS wordpress queries
- How to count post meta key values for all posts in database
- Sorting Posts by custom field
- Use post__in and post__not_in together?
- How to pass custom parameter to WP_Query for filtering in pre_get_posts
- Query with pre_get_posts to get pagination
- Group posts by meta_key
- What should I use, get_posts or wp_query for less CPU load?
- Different Results with query(‘s=computer’) vs get_posts(‘s=computer’)?
- How to get post from all Blog Multisite to the Main Site?
- How to search for posts IN OR title OR content OR author?
- Single page theme that uses pages for the content
- how to retrieve specific product attribute value in an sql query?
- WP_Query hit max joins… How else can I build a search function that uses custom fields?
- WP Query post meta value
- WordPress custom search form with pre_get_posts not work
- Get all posts without tags
- Would this post meta be better added to the post table rather than post_meta table
- get_posts() seemingly ignoring post_type
- If orderby parameter using pre_get_posts is the same for multiple posts what fallback does the query use?
- How to target the default Recent Posts and Recent Comments widgets with pre_get_posts?
- How to find out what “Blog pages show at most” is set to [duplicate]
- Count posts returned by get_posts in external PHP script
- order by multiple meta keys in pre_get_posts
- Order By Multiple Meta Fields
- meta_query on a date range using an array of values
- Trying to check and see if a post has a featured image outside of the main loop
- How to speed up wp_query, took more 5s to run against 100k posts
- How to sort posts in admin by titles with dd.mm.yyyy format?