No. There isn’t. The only way to add custom joins to a WordPress query is through the posts_join
filter or posts_clauses
filter, which contains all the parts of the query.
Those filters receive the WP_Query
object as a parameter though, which allows you to create custom arguments for WP_Query
that will affect the query.
function wpse_303758_posts_join( $join, $query ) {
if ( $query->get( 'custom_arg' ) === true ) {
$join .= " LEFT JOIN my_table ON $wpdb->posts.ID = my_table.post_id";
}
return $join;
}
With that filter the JOIN
will be added to the query if custom_arg
is true in WP_Query
:
$query = new WP_Query( array(
'custom_arg' => true,
) );
Related Posts:
- Order by DESC, ASC in custom WP_Query
- Exclude or Include category ids in WP_Query
- Secondary Sort (fallback) for WP_Query
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- Query Posts in a Predefined Order
- How to stop wordpress to make the default query?
- WP_Query based on URL parameters
- Order by meta_value_num DESC and meta_value ASC on WP 4.0
- How to query for a week using key => value WP_Query argument notation?
- How to use filter hook posts_join for querying taxonomy terms in posts_where?
- How can I style future post?
- List taxonomy terms plus their latest post ordered by post date
- WordPress altering my custom query, How to fix it?
- Looping through tabular data
- Order by meta_key in custom post type doesn’t affect the query
- Is there a PHP function that can match anything after the given URL, so my IF statement will work in each instance?
- How to create/modfiy WP_Query to search in post title OR custom field?
- Add a default meta_value to new posts
- How to detect custom query inside `posts_where` hook?
- WP query exclude post within the last month / only show over 1 month old
- WordPress query for most recent posts from multiple categories
- Pass array of taxonomy terms to wp_query
- Modifying the Search Results
- Offset Page Loops and Pagination
- How to find a post id using the post_excerpt?
- Comparing dates in custom field
- reducing the amount of wp_query calls
- List of the years with posts presented
- Use post object from first query in second query
- Getting post revision and printing them on the post content site
- Editing the default wordpress search
- Slow page loads due to WordPress Core Query
- Adding column to wp_posts table or join wp_posts table with another table
- meta_value_num not ordering all items
- Meta Queries – should nesting work after WP 4.1?
- Is there a better way to pull in custom content without querying posts?
- WordPress | Date not always appear [duplicate]
- Pass $page_id to new WP_Query
- Can I modify a WP_Query instance or clone it with modifications?
- Include posts from some categories while excluding from others
- Show a 404 error page if Public query variable’s value doesn’t exist?
- WP_Query within function within WP_Query
- Multiple Rows in a using wp_query
- If have posts a week old, display, else display a different loop
- Daily drip of posts – based on user ‘startData’ – ordered oldest to newest
- How to add tax_query to $args with concatenation
- Change AJAX filter from POST to GET for URL Parameters
- Where is the extra SQL fields coming from?
- Create a notification for post field
- WP_Query to get post on frontpage
- When listing child pages run out of memory
- Function to retrieve IDs of posts, cache results, and improve wp_query
- Why is get_the_excerpt returning full content
- How to avoid filling up an array each time I run a WP_query?
- How to SQL query posts IDs by categories AND authors?
- Search.php – return number of results but cannot loop through
- Admin: Custom Query Returning Permissions Error
- How to get pages of parent (non-recursive)?
- wp query remove posts from query then update max pages and posts found
- WP_Query Orderby meta_key and hide some meta_key
- Show X taxonomies of the latest published posts
- Combine query in WP_User_Query()
- Combine relationship posts with existing wp_query
- Custom wp_query inside a conditional stament inside a template part doesn’t work: why?
- Slick slider for post doesn’t display anything
- What is the equivalent WP_Query of a SQL Query?
- create custom shortcode wp and put php code in
- WordPress Query custom ordering by temporary variable
- Check the stored / cached WP_Query with transients on post change
- New template file does not load category-specific post
- use mysql variable in a $wpdb->query to reindex a column?
- How to get only present and past posts with post_date
- How to create better WP_Query to look for date time which is anywhere between two meta values?
- Query WP Posts, then list the taxonomies from those posts
- Query post with content only
- Load WP Query with Ajax
- Displaying Pages in Nav Sub-Menu with Specific Taxonomy Terms?
- WPQuery loop not giving expected output
- WordPress tax_query ignoring relation OR
- pagination functions are not working
- Gather same custom field values in one value in a select tag with wp_query
- Fetch only categorized posts
- Wrap group of wp query posts to parent div by date/year
- Continue loop after $queryObject
- Order Posts By Youtube Views
- Wrote a WP Cron Plugin and it triggers a fatal error upon activation
- Declare inline background image in functions.php
- Custom query from all posts & all child page from one parent page?
- Get the type of an advanced custom field (ACF) in a WP_Query loop [closed]
- wp_query conditionally get posts
- Getting Year & Date inside wpdb [duplicate]
- loop through custom post types with meta data
- Looking for a way to exclude frontpage and nav menu from query filter
- Using Query In Post Type Archives
- WP Query Obj: Set value to be unequal | Hide media by admin
- the_excerpt() not working in custom archive
- Get posts by meta value except one post [closed]
- wp_query, calculate with two dates when ‘key’ is text format
- Use value from meta key array for use in WP_Query
- WP_Query sort by ACF date field (newest first) with blank dates first