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
- WP_Query vs get_posts
- Get posts from Network (Multisite)
- Reduce or prevent calling of update_meta_cache
- Using OR conditions in meta_query for query_posts argument
- Sanitation needed for WP_Query or get_posts calls?
- Use of caller_ get_ posts
- Get posts by menu ID
- Extending WP_Query — Optimise SQL query
- How to filter sql only for a specific post type
- Meta Query with date and time on the same Day before given time
- Get posts with condition on comment meta value
- Stop all SQL_CALC_FOUND_ROWS wordpress queries
- How to count post meta key values for all posts in database
- What should I use, get_posts or wp_query for less CPU load?
- How to get post from all Blog Multisite to the Main Site?
- WP_Query hit max joins… How else can I build a search function that uses custom fields?
- How to target the default Recent Posts and Recent Comments widgets with pre_get_posts?
- 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?
- Filter WordPress posts by between parameter
- How to Modify Taxonomy Archive Page with Search Parameter?
- Including only current user’s posts in search
- How To Get Some Data From WordPress Database Using WordPress $wpdb Query?
- WP_Query, tax_query and term_meta: How to?
- get_posts – get all posts by array of author
- $wpdb select date range of posts
- get_posts() not working with multiple statuses
- Return only post(s) which have post_excerpt
- Performance when getting post meta for post retrieved by meta value
- Show Sticky Post at the top but do not show again in the loop?
- Query that loads a custom type AND posts whose ids are not inside those custom types custom fields
- Remove category from query (show all posts in archive.php) pre_get_posts()
- WP Query related posts by tags
- hide custom post types with specific meta key ON admin backend
- Help ordering Post loop by two meta values
- WP_Query post_parent parameter always returns children of current page
- How to count posts with specific arguments
- How to pass orderby params to $wpdb->prepare()?
- how update data through ajax and jquery
- pre_get_posts – Trying to get property of non-object warning
- Getting additional columns from sql
- get_posts output always same post
- complex get_posts() query to select child pages
- Using get_posts to get posts based on a checkbox value with Advanced Custom Fields
- Slow Query On Search
- pre_get_posts – editing query, tax_query
- Child pages not affected by orderby
- How to get posts by category and by choosing a taxonomy term?
- Function using get_posts() with tax_query not working when called from functions.php
- Search for pages with permalink
- Execute PHP function inside the admin area
- get_var is neither a string, integer, or array …?
- Prioritising and Ordering Posts By Category Name Using A Custom Loop
- Populate select list with meta values from all posts of a Custom Post Type
- Form checkbox value going to dynamic URL
- SQL to join u3g_users & u3g_meta_value with repeating data
- get_posts return only first result
- How to get meta key list efficiently?
- how to get wp_query posts only first letter of alphabet A?
- Pre get posts sort by meta key returns no results if meta key does not exist
- Case insensitive ORDERBY in wpquery
- Pre_get_posts only show posts by administrator roles
- Modify a query with no results in pre_get_posts
- How order by works?
- Custom Order Current Query: By Meta Key and Category
- Order Posts By Custom Field That is an array of objects
- Calculating efficiently on large amount of data generated by wp_query
- Include post_status check within $wpdb query
- Ordering Posts by parent category, name ascending
- Use not custom fields in get_posts() meta_query?
- WP_Query always returning the last custom post
- Mathematical operations on custom field values? (updated)
- wp_query – Modify $query to include duplicate content
- Filter WP_Query output before it is accessed (pre_get_posts)?
- get_posts works but new wp_query doesn’t
- Why WP_Query in functions.php is not working when get_posts works?
- meta_query dates from an array
- Query specific number of posts for each post type in specific order
- Avoiding page loop
- get_posts shows current post, not defined posts with args
- Add custom argument to WP_Query and modify SQL where clause
- How to cache wordpress get_posts query using transients?