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:
- count post meta values
- wpdb->get_var – count author posts, meta value
- Count Post and Page Views based on meta_value Using Shortcode in Dashboard Widget
- Check if Post Title exists, Insert post if doesn’t, Add Incremental # to Meta if does
- What is the different between an attachment in wp_posts and an attachment in wp_postmeta?
- Sanitizing integer input for update_post_meta
- if get_post_meta is empty do something
- Meta compare with date (stored as string) not working
- How to update/insert custom field(post meta) data with wordpress REST API?
- Front-end update_post_meta snippet displays white screen?
- Give extra post-meta to RSS feeds
- How to get meta value in wp_attachment_metadata
- Clean up output added via wp_head()
- Can’t translate the post meta data (Date) in another language
- Get post from meta_key and meta_value
- get_post_meta returns bool(false)
- How to get custom post type to display post meta on archive pages?
- WP_POSTMETA changes site crash
- meta_post_meta return value 1
- How to use post_id with a Class?
- get_post_meta remains empty while looping all menu items and using the ID
- Set default Custom Post Meta Value
- How to stop wp_postmeta from being called on archive and search pages?
- INSERT ON DUPLICATE KEY UPDATE failes in postmeta table
- Set Checkbox as checked by default
- running function during post save and adding variable to post meta
- replacing the_autor or make callback
- Some post meta fields stop saving after a few successful saves
- Save an array of values in the post meta box
- Custom post meta values reset by autosave [duplicate]
- Compare meta_query with a Regular Expression and do a less-than operation on it
- get_post_meta() empty in preview WHEN custom post is published [closed]
- Add Embed.ly API objects to post_meta on update
- Editing does not change post_name
- Compare string with post id in wpdb and do stuff when match is found
- $wpdb class updating meta_value using Ajax [closed]
- cleaning up safely wordpress wp_postmeta table
- How to selected which tags to print, instead of printing the whole tag list?
- Why does get_transient() always return string even if integer set?
- Author_meta ONLY if it exists
- query posts and split meta information into separate div’s
- How to test the outcome of a wpdb query?
- add unique string as custom-field to every post
- How do I insert a new meta key / value pair, but only if another meta key is present?
- “Cannot use import statement outside a module” JS error while adding a custom meta block?
- Gutenberg featured image checkbox – checkbox not correctly set on editing page reload
- How to properly use oneOf and anyOf in Rest Schema?
- Get the author meta adds now
- wordpress is_front_page() issue
- show ad after # paragraphs
- If ACF meta_key has meta_value
- update_post_meta not working?
- How we can get “get_post_meta” of specific user who added it
- Change wordpress meta tag description using WP functions
- Repeated nav bar queries failing to be cached
- Randomizing Post Links Outside of Loop – No Author or Date
- help to decipher wp metadata
- Cant create or update meta fields using WordPress REST API
- Filter posts by meta key
- Display current ranking of post as a number in post title
- Insert Custom Field Value
- SQL query – get a featured image’s alt / alternative text
- I can not display meta value in extras.php and template-tags.php
- update_post_meta() updating nested array in Multidimensional array with empty sub-array
- Post Thumbnail missing when using webp format while sharing
- How do I list taxonomies that have upcoming events in WP? Is there a way to do this without having to query posts first?
- Sorting my posts on homepage my specific value in post_meta table
- Bulk Update Post Meta Values from Different Post via Rest Api
- Strict comparisons problem when using boolean post meta
- Why is the actual number of thumbnail images not matching what is store in an attachments metadata?
- How to register post meta with multi level arrays?
- Check if any meta on the post has value then display content
- If I disable screen options, does WP still try to update post meta?
- Combine meta query and give a specific meta query a higher priority
- Meta data being pulled from wp-login.php
- Get table parameter and save in meta value
- How can i show post views using specified post ID?
- How to add/update post meta to use in query?
- gettext localization is not working
- Rename image filename using ‘media_handle_upload’
- Move Entry Meta Above Title in Archives (Genesis + Brunch Pro)
- Update Post metafield of specific categories
- Using Self Hosted Video URL With Custom Fields
- Exclude category from DB query
- How to sort by meta value num, but ignore zero value?
- Create a Gallery and update Post Parent of Attachment Images
- Update event post meta each day automaticaly
- Problem serializing single quote and double quote into post meta
- Storing post_meta fields in array
- Advanced Custom Field — grabbing post_meta from previous post
- Fetching array of postmeta with $wpdb and in_array conditional
- Piklist File Upload
- update_post_meta() not working in bulk option
- How to create a link for wordpress meta datas?
- Fetch post meta data on POST request
- Which query method to use? (edit- wpdb syntax problems)
- How to update post meta with xml data
- get_children filter with postmeta
- Auto save title as custom meta field value
- Post meta box data not saving