You can do that. There are filters available in WP_Query that enable you to modify the query just as you like. The filter posts_clauses
filters all of the parts of the query together. There are also filters specific to the parts of the query too. The best way to know about them is, search posts_clauses
in “wp-includes/query.php”. Just 3-4 lines before this filter should be a series of filters to filter out the full query part-by-part. The filter tags are self explanatory & you can experiment with them to see which combination works out the best for you
Related Posts:
- How to print the excuted sql right after its execution
- Pagination with custom SQL query
- Return only Count from a wp_query request?
- how does $wpdb differ to WP_Query?
- Is it true $wpdb->get_results is faster than WP_Query in most cases?
- Query causing load because of SQL_CALC_FOUND_ROWS post counting?
- Use WP_Query with a custom SQL query
- How to make an activities stream mixing posts and comments?
- How can I connect to another WP database and use WP_Query?
- Get number of comments after modifying comment query
- How to change a custom query into a standard loop?
- How to count data records in wordpress which have same meta_value in wp_postmeta table?
- Should close $wpdb via $wpdb->close()
- $wpdb->insert inserting two rows in database
- Get the Plugin Which Triggered a MySql Query in WordPress?
- How To Get Some Data From WordPress Database Using WordPress $wpdb Query?
- Detect featured image among the attached images
- How would I format a query that depends on post parent taxonomy
- Mysql query LIKE not working
- Select from wp_post and multiple meta_value from wp_postmeta
- Order by custom table and multiplication
- How to correctly pass values to wpdb->prepare()?
- $wpdb select date range of posts
- What’s the purpose / logic of split_the_query in WP_Query->get_posts
- WPDB query – decrypting DB data
- How to delete taxonomy term when a wordpress user is removed?
- Custom Query num_rows returns wrong amount
- Getting post revision and printing them on the post content site
- Filtering posts from different categories into different section by doing WP_Query only once
- Iterating through $wpdb query without using get_results for large query results
- Query with search and subscribers only output
- wp_Qwery works to slow
- How to query custom post types with mixed AND & OR statements for custom fields
- Query most popular terms by taxonomy over 2 week period
- Which is faster wpdb & get_row or wp_query & ge_post_meta?
- Custom query: Get all posts that are from a certain category?
- How to access custom WordPress database tables
- How to pass orderby params to $wpdb->prepare()?
- Ajax future single post query doesn’t work when NOT logged in
- Conditional sorting with variable using WP Query
- Is it safe to access the underlying mysqli object from \wpdb for custom queries?
- Make a SQL query with wpdb in WordPress
- WordPress query posts with multiple post_meta data
- List of ways to access WordPress database?
- Specify strict ‘order by’ in WordPress query
- Does WordPress have something like Drupal’s DB API?
- get_post() is not returning correct value
- Disable (or limit) queries when certain content (or data) is not needed (or showed)
- get_var is neither a string, integer, or array …?
- Use have_posts() with array of post results retrieved by $wpdb->get_results
- how to translate countries output from wp database?
- What’s wrong with this wpdb query?
- duplicated posts when using pagination
- Passing a SQL query to the WP Query
- Save queried result into database
- Any way to use FETCH_KEY_PAIR with $wpdb?
- Doing $wpdb->get_results returns NULL, doing the same query in my DB returns correct value
- How to get user avatar via WPDB
- In which file to use $wpdb and its functions for database operations and queries in wordpress?
- What argument does my function need to echo get_results() query results
- complex query question
- Select Unique Posts for a List of Tags
- How To Use WP_Query To Get The Custom Post type Posts With Keywords
- Include post_status check within $wpdb query
- wpdb get_results() returns only 2 rows
- Optimising amount of calls to custom fields
- pre_get_posts or $where, which one to use?
- Fire query on ajax post url page
- Slow getting posts from category
- Search Query that Includes Custom Table
- Custom query (author is post_author or meta co_author) with Pagenavi pagination
- Different sql queries count indicator on the main page [closed]
- wpdb LIKE request shows all database data
- Convert a WP Query into a simpler SQL query to fetch only COUNT of posts
- How much does $wpdb->prepare(), then $wpdb->query() VS straight $wpdb->query(), can slow down the load time of whole page
- how to use transient method?
- get_post_meta bringing back results, but $wpdb->postmeta doesn’t
- Is there another way to retrieve a post_id from post_meta other than a SQL query?
- Query all posts where meta value is empty
- wp query by search in titles only & put the posts in loop
- List the 5 most recent child pages
- Meta-value query
- Complex Orderby Parameters: How to query with multiple orderby parameters using meta_value_num?
- new WP_Query(), have_posts() return false in user_register hook
- Masonry, WP_Query & paged – first page repeating, second page not loading
- REST API: Limit Read Permissions for Default Endpoints
- How to sort post by custom table value
- wp_query to print posts if have X custom field value
- How to combine two WP_Query objects?
- Is it possible to retrieve posts depending on meta_key LIKE condition? [duplicate]
- Widgets: Show Recent Posts Only if the Posts Have Both Categories X and Y
- Populate select list with meta values from all posts of a Custom Post Type
- WordPress Meta Query Null Values Order
- WooCommerce WP_Query using tax_query returns no results (0 = 1)
- make query more simplest and in one query
- How to allow Readers to Select Post Order?
- 423 queries in 6.098 seconds
- Combine privileged users array with my current query
- How to write a query-function as a query-shortcode?
- wp_query, calculate with two dates when ‘key’ is text format