You can always use posts_clauses
filter and add processing for tax_query in there (you don’t even need to write your own SQL):
function filter_single_with_tax_queries( $clauses, $query ) {
global $wpdb;
if ( $query->is_singular ) {
$query->parse_tax_query( $query->query_vars );
$tax_clauses = $query->tax_query->get_sql( $wpdb->posts, 'ID' );
$clauses['join'] .= $tax_clauses['join'];
$clauses['where'] .= $tax_clauses['where'];
}
return $parts;
}
add_action( 'posts_clauses', 'filter_single_with_tax_queries', 10, 2 );
Related Posts:
- How to add taxonomy filter on the query fly?
- RSS feed with specific keyword
- How to Modify Taxonomy Archive Page with Search Parameter?
- Including only current user’s posts in search
- WP_Query – How to get all posts of specific days of week by custom field date?
- Elementor posts custom query based on tag [closed]
- Filter WP_Query output before it is accessed (pre_get_posts)?
- When to use WP_query(), query_posts() and pre_get_posts
- Should I use Pre Get Posts or WP_Query
- Using pre_get_posts with WP_Query
- WP_Query orderby post__in remains ineffective in the Loop [closed]
- WordPress tax_query “and” operator not functioning as desired
- Custom taxonomy query broken after upgrade to 4.4
- What is “main query”? [duplicate]
- Show posts without term
- Reduce or prevent calling of update_meta_cache
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- Hook/action after WP_Query gets posts to query custom tables for post-related meta
- How to uniquely identify queries?
- Order Search Results Page by meta_value If no Value Return Remaining Results
- pre_get_posts with get_posts
- How-to exclude terms from the main query the most performant way?
- Changing Posts Per Page and offset with pre_get_posts
- Display posts the match taxonomy term linked from wp_list_categoies?
- Query two taxonomies via URL or link?
- Slow SQL_CALC_FOUND_ROWS Query
- “pre_get_posts” firing on every query
- Is there an action/filter called when WP_Query->query is finished and assigns posts
- Using is_main_query to select custom post type on certain page
- Multiple orderby parameters in pre_get_posts() action
- Counting number of posts with Category B in Category A
- SQL Statement generated by WP_Query not producing expected results
- Custom archive page based on array of categories and tags
- Select posts wich has no relationship in custom taxonomy
- Sorting Posts by custom field
- How to pass custom parameter to WP_Query for filtering in pre_get_posts
- Query with pre_get_posts to get pagination
- Recommended way to drop a pending query (in pre_get_posts)?
- Single page theme that uses pages for the content
- Display different number of posts from one category on the different pages
- List taxonomy terms plus their latest post ordered by post date
- Querying by taxonomy vs Querying by Custom fields Speed Comparison
- WordPress custom search form with pre_get_posts not work
- If orderby parameter using pre_get_posts is the same for multiple posts what fallback does the query use?
- Can not switch the queried post in pre_get_posts hook
- How to target the default Recent Posts and Recent Comments widgets with pre_get_posts?
- Filter and list posts of a custom taxonomy
- pre get posts changing the query
- order by multiple meta keys in pre_get_posts
- Which filter/action hook gets triggered after a query has been performed?
- How to show only one post for each categories of taxonomy of custom post that contains a specific custom field
- How to sort posts in admin by titles with dd.mm.yyyy format?
- tax_query shows no results if nothing is selected
- WP_Tax_Query with post_tag not working
- Splitting the main query in multiple loops with query_posts and/or pre_get_posts?
- Using pre_get_posts to Filter Posts
- Get array of current post term ID’s
- Using pre_get_posts on a specific core/query block
- Searching through different categories on different pages code is not working
- Setup of taxonomy term template pages
- How to display future posts – modified query still yields 404
- Display link to taxonomy archive only if it has posts with certain custom field values
- How to do a query on custom taxonomies that is uncategorised?
- pre_get_posts filter meta_query without conflicting existing meta_query
- When querying a combination of posts and other meta fields, is there a better solution than directly modifying the WHERE value?
- How to change posts order on Category and Tag archives?
- WP_Query, tax_query and term_meta: How to?
- Order taxonomy terms in alphabetical order
- Query Custom Post Type Order By Taxonomy Field
- Formulate a url to show posts with both taxonomy terms
- My Main Query Modification is Messing up my dynamic main – why?
- Offset Page Loops and Pagination
- pre_get_posts Remove tax_query Completely
- Query post from all category with same tag on 1 pages
- Query with custom taxonomy not working
- pre_get_posts order by not working
- Adding a parameter to the default query
- Using WP_Query in “parse_query” or “pre_get_post” in Posts2Posts
- Single meta_query query using OR instead of AND in request’s WHERE statement
- How to choose between hooking into per_get_posts or into parse_query
- Function get_queried_object() return NULL in custom taxonomy
- Getting Taxonomy inside WP_Query Loop
- Order posts by taxonomy count
- Store sticky post’s ids in a transient
- showing all search result in one template
- Querying on multiple taxonomies pulled from $_GET checkbox array not working?
- List custom taxonomy terms sharing posts with a term from a second custom taxonomy
- How to change main query based on post meta
- new WP_Query to get max price meta value not working
- Query custom post type by custom taxonomy (category slug)
- How to Filter Posts by Custom Fields?
- Display posts from only one post form in custom query and exclude in main query
- Show Sticky Post at the top but do not show again in the loop?
- WP_Query, pre_get_posts and offset
- Complex WP SQL Query
- Using meta_query with multiple keys and compare values
- Can I set my WP_Query to be a Main Query?
- Remove category from query (show all posts in archive.php) pre_get_posts()
- add_actions called from functions.php not returning good values
- Show scheduled posts in main loop but not in WP_Query?