You have a structural problem with your data. Serialized data in the database is terrible if you need to search over pieces of that serialized data.
- There is no reliable, efficient, and certainly no easy, SQL query to
search over serialized data. “serialization” is a PHP mechanism. It
isn’t SQL. To the database that is just a string. Your only SQL choice is a regex on the string. WP_Query
certainly won’t do it. That functionality is not built in, probably for the reason listed above.
Iterating over the data is about the only solution you have given the data structure you are dealing with.
However, the correct solution in my opinion is to alter your data structure so that you are saving granular pieces of data in the database. In other words, use a lot of different keys for the values that you need to search over.
Related Posts:
- Use REGEXP in WP_Query meta_query key
- Group posts by meta_key
- Would this post meta be better added to the post table rather than post_meta table
- Performance when getting post meta for post retrieved by meta value
- Using hook to use DISTINCT in a wp_query
- Which is faster wpdb & get_row or wp_query & ge_post_meta?
- Query postmeta based on meta_value, return array of post_id
- How to count post meta key values for all posts in database
- How to only display posts whose meta_value field is not empty?
- Can wp_query return posts meta in a single request?
- order by numeric value for meta value
- How do I query for posts by partial meta key?
- Return only Count from a wp_query request?
- WordPress retrieving meta data for all custom post types in list view
- Order by optional meta key?
- Order by DESC, ASC in custom WP_Query
- How to prevent execution of default query, while preserving ability to use WP_Query in template?
- meta_query: using BETWEEN with floats and/or casting to DECIMAL
- Reduce or prevent calling of update_meta_cache
- Is there a way to extend WP_query so Custom Post Types can have properties?
- What is the most efficient way of querying posts based on visits and date for current day?
- Getting attachments by meta value
- WP_Query displaying ALL posts
- Get posts by menu ID
- meta_query where value is equal to given value
- Slow SQL_CALC_FOUND_ROWS Query
- Query Custom Meta Value with Increment
- WP-CLI How to generate a list of posts with corresponding meta values
- What is an efficient way to query based on post_meta?
- WP_Query not working as expected for attachments and custom meta_query
- SQL query equivalent to WP User Query
- What’s wrong with this WP query?
- Stop all SQL_CALC_FOUND_ROWS wordpress queries
- How should I use posts_where to change meta_value from a string to integer?
- How to search for posts IN OR title OR content OR author?
- How can I create a WP_Query that returns posts where one meta_value
- WordPress altering my custom query, How to fix it?
- WP_Query hit max joins… How else can I build a search function that uses custom fields?
- WP Meta Query for some meta (array) values
- WP Query post meta value
- Custom URl parameter
- query posts in functions.php and update a field
- Compile meta values from custom loop into array and then calculate sum total
- How to get sum of meta_values of a meta_key in wp_query according to conditions
- how to fire join query with post_meta
- Order By Multiple Meta Fields
- Best approach to create Hot and Trending sections
- meta_query on a date range using an array of values
- WP_Query, custom sort and custom filter
- How to speed up wp_query, took more 5s to run against 100k posts
- SQL User Query by Multiple Roles using PHP
- Order posts by meta value and Date
- Efficient way to update multiple post meta
- WordPress Query is taking more then 20 second and stuck on creating index
- How to make orderby ‘meta_value_num’ OPTIONAL?
- Get the Plugin Which Triggered a MySql Query in WordPress?
- Query Posts depends on custom field inside repeater field using acf
- Query post with meta_query where date is not in future
- Minimising Database Queries when using Advanced Custom Fields
- Mysql query LIKE not working
- How to get posts on a specific date – WP Query
- Using WP_Query and WP_Meta_Query Outside of WordPress
- Get meta info related to current post
- Select from wp_post and multiple meta_value from wp_postmeta
- Pull post meta with post_query?
- How to find exact match for search term in WP_Query? What is the additional string added in LIKE query in WP_Query?
- Improve wp query perfomance on large db
- Order by custom table and multiplication
- Group WP_Query by meta_key date
- Single meta_query query using OR instead of AND in request’s WHERE statement
- WP_query posts closest to todays date
- why update and delete query not worked in custom table?
- exclude posts with a specific custom field and value
- Inserting serialized value into wp_postmeta using update_post_meta
- How to use MySQL’s MATCH AGAINST in WP_Query?
- Slow WP_Query for custom post type
- How to make Meta Query case sensitive?
- Get attachment by meta_key value
- Hide Administrators From User List except current user (administrator)
- Display custom field meta outside loop, site wide
- Add “Category” to Mysql Query
- Mysql query and order meta value
- Help with WP_Query – Too many mySQL queries
- pagination with ‘no_found_rows’ => true,
- Fetch Record based on meta key dates
- Order by summing multiple values
- Where to put meta Keys
- how to make members list directory through wordpress post custom meta key.
- How to implement a new row_count method in WordPress?
- How do I query for posts by partial meta key?
- Large AND OR query timing out
- Wp query show post by author name or post title or post content
- get_post_meta slowing down my page load (in a plugin)
- New WP_Query loop in admin causes problems
- echo a specific meta_key queried through a custom post
- How to increase load time of an archive/search page (WP_Query)
- Query most popular terms by taxonomy over 2 week period
- get_post_meta in WP_Query
- Hide posts with meta key in WP_Query
- how update data through ajax and jquery