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
- How to count post meta key values for all posts in database
- 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 only display posts whose meta_value field is not empty?
- Can wp_query return posts meta in a single request?
- 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
- Is there a way to extend WP_query so Custom Post Types can have properties?
- Getting attachments by meta value
- meta_query where value is equal to given value
- 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?
- WordPress altering my custom query, How to fix it?
- 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 fire join query with post_meta
- Order By Multiple Meta Fields
- meta_query on a date range using an array of values
- WP_Query, custom sort and custom filter
- Efficient way to update multiple post meta
- WordPress Query is taking more then 20 second and stuck on creating index
- Get the Plugin Which Triggered a MySql Query in WordPress?
- 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
- 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
- Group WP_Query by meta_key date
- why update and delete query not worked in custom table?
- Inserting serialized value into wp_postmeta using update_post_meta
- Hide Administrators From User List except current user (administrator)
- Display custom field meta outside loop, site wide
- pagination with ‘no_found_rows’ => true,
- Fetch Record based on meta key dates
- how to make members list directory through wordpress post custom meta key.
- How to implement a new row_count method in WordPress?
- Large AND OR query timing out
- get_post_meta slowing down my page load (in a plugin)
- echo a specific meta_key queried through a custom post
- Query most popular terms by taxonomy over 2 week period
- Filter posts by comparing custom meta value against postdate
- WP_Query – Accessing MetaValue from Query Result
- search serialised meta_value for date value?
- how to get Nearby zipcode
- How I can change the condition or compare operator for WP_Query in pre_get_posts
- mysql query order by
- Order WP_Query results by meta key value in custom query
- How can I update post meta inside a WP_Query loop or the WordPress loop?
- Orderby two meta fields not working
- Query posts by searching for a string in a meta field
- get_var is neither a string, integer, or array …?
- SQL query injection with fifu image
- How do i create a custom post query when the meta value is an array?
- WP Query – grouping posts by same meta key, adding together values from another key
- Woocommerce Get Orders By Meta Value
- show most viewed post
- Display posts from multiple value in meta separated by comma
- Why can my filter query SOME metadata but not other metadata?
- use mysql variable in a $wpdb->query to reindex a column?
- Query against multiple locations within single custom post type post
- Fix wp_term_relationships slow query in get_posts
- WordPress Query optimaization for slow query
- update_post_meta performance in a loop woocommerce
- Sorting query_posts() with a complex orderby filter
- I need query_posts() to order results first by a meta value and then by post ID
- Look for string in posts and postmeta
- Order Posts By Custom Field That is an array of objects
- Slow query when selecting with large meta query or post__in
- Meta key in wp_query bug?
- WP Meta Query at depth 2
- WP_Query with child element
- WP_Query always returning the last custom post
- Sorting Posts with meta value not working
- Return a single custom post from multiple meta queries
- How to query post ids liked by the Author
- loop through custom post types with meta data
- Different sql queries count indicator on the main page [closed]
- Parsing External Table Arguments
- WordPress query very slow on +/- 300k DB entries and 7 INNER JOIN
- WP_Query by meta key not returning any posts
- Bulk delete comments, foreach loop
- Extend search query to search meta keys values based on search string