WordPress is also provide more filters to change custom queries.
https://codex.wordpress.org/Custom_Queries
add_filter('posts_join', 'custom_query_join' );
$premium = new WP_Query( $premium_args);
remove_filter('posts_join', 'custom_query_join' ); // remove filter bcz not effect to another query to use after this query.
function custom_query_join( $join ){
$join .= 'Put here join to table';
return $join;
}
Related Posts:
- Meta_query compare operator explanation
- WordPress get_posts function, 1300 lines long
- Exclude a category if post is only in that category using wp_Query
- Too slow when using both ‘tax_query’ and ‘meta_query’ both in WP_Query
- Use of caller_ get_ posts
- Tax_query terms ID’s using variable
- Custom query incorrectly returning everything [closed]
- Pagination custom query
- WP_Query and name__in
- Query certain amount of posts from multiple dates
- How should I use posts_where to change meta_value from a string to integer?
- Reduce Database Queries in Code [duplicate]
- How to get post from all Blog Multisite to the Main Site?
- Sort in WP_Query(), not filter? Is it possible?
- Better to make new wp_query or only modify main query each time?
- Using WP Query to search within ALL keys in meta query
- How to display images in related posts?
- Search product by brand name in wp_query
- What is the difference in a query when using a fieldname as a meta key vs orderby field?
- Get all post IDs from current WP_Query – not just currently visible
- WP User Query multiple AND OR query problem
- $wpdb->insert inserting two rows in database
- Php Trying to get property ‘ID’ of non-object
- More than 1 Year Date Query
- Is it possible to dynamically get queried term AND taxonomy?
- posts_per_page not working
- WP Query for variable taxonomies
- WP_query Date Range results not matching loop
- Pull post meta with post_query?
- How to use WP_Query to display many posts?
- Meta Query relation “AND” not working
- Complex WP_Query (two post types and multiple operators)
- Five posts from a category in footer
- Return only post(s) which have post_excerpt
- Add quicklink to in the Admin posts page where I can query by a meta_key
- Remove category from query (show all posts in archive.php) pre_get_posts()
- Front page with registered query params in URL shows blog archive instead of front page
- Order by empty custom field
- Warning: Invalid argument supplied for foreach(). when creating a WP_query
- Help ordering Post loop by two meta values
- Display most popular in the past two days
- How to exclude post formats from wordpress recent posts in a tabs widget [closed]
- New WP_Query loop in admin causes problems
- How to sort a custom wordpress query by combination of meta values?
- How to pass orderby params to $wpdb->prepare()?
- Get author if post has multiple authors
- Hide posts with meta key in WP_Query
- how update data through ajax and jquery
- What happens to the default query when I use WP_Query?
- Modifing archive query affects show post count function
- For what queries is conditional tags informative?
- Utilising an existing page while using the “s” query parameter
- posts archive page – closing WP_Query loop correctly [closed]
- JSON – Create rest api endpoint for Advanced Custom Fields
- Query_vars support in Rest API
- Is it possible (and how to) query single Gutenberg blocks?
- Continue or break the while loop
- Get meta_value of a specific meta_key from all posts belonging to a specific custom type
- Nested array issue in meta_query
- Query by key or author
- Why doesn’t my WP Meta Query return any results?
- How to build the WP_Query using the code?
- How go give $value to wp_query
- Show multiple tax_query from 2 or more post_type in a single code
- Disable (or limit) queries when certain content (or data) is not needed (or showed)
- How to make the ‘request’ filter work?
- How to use rewind_comments() – when and how to use it?
- How to make a query returning pages from multiple parents
- create a custom query for posts managed by Restrict Content Pro
- Related categories order posts by category
- Why pagination is not working with tax_query param?
- Finding post ID dynamically on click
- paginate_links method doesn’t show second page of my custom wp_query
- Wp_Query Post per page not working?
- Order Element By Custom Field in WordPress
- Display All Top Child Categories / Taxonomy
- how to get custom attachment url?
- ACF Post Object meta-query by title not ID
- Case insensitive ORDERBY in wpquery
- Sorting with meta_query and multiple, optional meta keys
- getting posts by tags
- WP_Query & Duplicate entries
- Query child posts with tax query on parents
- How to break up output of posts for different terms on same page?
- From admin edit user page query either the user_nicename or username field value of the user profile being edited or viewed
- Get posts by similar names and categories
- Calculating efficiently on large amount of data generated by wp_query
- Include post_status check within $wpdb query
- Return on a quest all these meta_value
- Complicated WP_Query
- Filter WP_Query output before it is accessed (pre_get_posts)?
- Divide WP_Query posts by date & post type
- Custom query to show posts
- New WordPress WP Query using posts from certain categories
- Taxonomy related query not working
- error with $query->have_posts()
- Multiple Orderby is not working right
- WP query based on two meta queries
- Query All Posts: Either Display Most Recent or One with Particular ACF Value Chosen
- Can I use WP_Query to find a post with a particular menu_order?