In general this would make sense at pre_get_posts
since you could just express conditions as meta query and let WP figure out SQL.
In your specific case this won’t work, since that format is horrible for programmatic comparison. Unless you can change format to something more friendly, you will probably have to write some pretty custom SQL to make it work.
Related Posts:
- When querying a combination of posts and other meta fields, is there a better solution than directly modifying the WHERE value?
- Should I use Pre Get Posts or WP_Query
- Using pre_get_posts with WP_Query
- Return only Count from a wp_query request?
- What is “main query”? [duplicate]
- Prevent pre_get_posts filter on specific post type
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- How to uniquely identify queries?
- pre_get_posts with get_posts
- Is it true $wpdb->get_results is faster than WP_Query in most cases?
- Changing Posts Per Page and offset with pre_get_posts
- “pre_get_posts” firing on every query
- Use WP_Query with a custom SQL query
- Using is_main_query to select custom post type on certain page
- Multiple orderby parameters in pre_get_posts() action
- How to make an activities stream mixing posts and comments?
- SQL Statement generated by WP_Query not producing expected results
- How do I create my own nested meta_query using posts_where / posts_join?
- How to use filter hook posts_join for querying taxonomy terms in posts_where?
- How to pass custom parameter to WP_Query for filtering in pre_get_posts
- Query with pre_get_posts to get pagination
- Single page theme that uses pages for the content
- WordPress custom search form with pre_get_posts not work
- order by multiple meta keys in pre_get_posts
- Should close $wpdb via $wpdb->close()
- WP_Tax_Query with post_tag not working
- Using pre_get_posts on a specific core/query block
- Get the Plugin Which Triggered a MySql Query in WordPress?
- How to change posts order on Category and Tag archives?
- Mysql query LIKE not working
- Formulate a url to show posts with both taxonomy terms
- Offset Page Loops and Pagination
- How to correctly pass values to wpdb->prepare()?
- 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
- What’s the purpose / logic of split_the_query in WP_Query->get_posts
- How to change main query based on post meta
- new WP_Query to get max price meta value not working
- Display posts from only one post form in custom query and exclude in main query
- WP_Query, pre_get_posts and offset
- Complex WP SQL Query
- 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
- wp_Qwery works to slow
- Filtering out child category posts from parent category archive not working
- Wp query show post by author name or post title or post content
- How to query custom post types with mixed AND & OR statements for custom fields
- Query most popular terms by taxonomy over 2 week period
- Shouldn’t I be able to modify the main query by this filter?
- Custom query: Get all posts that are from a certain category?
- using pre_get_posts for search results not found
- Ajax future single post query doesn’t work when NOT logged in
- Woocommerce – exclude only older out-of-stock items
- WP Query – order posts by meta field first and then order the rest
- Make a SQL query with wpdb in WordPress
- List of ways to access WordPress database?
- Specify strict ‘order by’ in WordPress query
- How I can change the condition or compare operator for WP_Query in pre_get_posts
- Does WordPress have something like Drupal’s DB API?
- WP_Query – How to get all posts of specific days of week by custom field date?
- 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?
- tax_query in pre_get_posts
- $wp_query->found_posts not returning correct value
- Elementor posts custom query based on tag [closed]
- Exclude post with taxonomy and from the terms (taxonomy & tag) posts count
- `offset` WP_Query argument dont work via `pre_get_posts`
- Replace wp_query with wp_user_query
- Make a products only viewable to a specific user ID in meta_query pre_get_posts
- pre_get_posts pagination not working
- Save queried result into database
- meta_query is overriding default search
- Any way to use FETCH_KEY_PAIR with $wpdb?
- order posts by a secondary query that counts items
- How to get user avatar via WPDB
- Woocomerce – Order products by float attribute in archive pages
- Order posts by title and custom field value?
- Limit default Search query to post_title
- why doesn’t this pre_get_posts code work?
- pre_get_posts with WP_Query to prevent posts from specific tags
- What argument does my function need to echo get_results() query results
- Using the same WP_Query for shop and widgets in WooCommerce shop
- complex query question
- Adding a Theme Customizer Control for Posts_Per_Page
- Order posts by custom column using pre_get_posts
- Fire query on ajax post url page
- Search Query that Includes Custom Table
- Looking for a way to exclude frontpage and nav menu from query filter
- pre_get_posts redirecting
- Custom post types loop on a page template
- 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 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?