Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Trouble with serialized metadata

For 99% of cases, no, you can’t.

Serialised data is not something you can search, and that is the fundamental problem. Not how to search it, but that it was serialised to begin with. Serialising is unnecessary. This is for the same reasons you cannot unscramble an egg, serialised data, especially PHP serialised data, is not built to be searched, neither is the database optimised for it.

So, the solution is to store the data you which to search for as independent post meta that can be searched. Or better yet, avoid ultra expensive post meta queries entirely and store the data you want to search by in taxonomy terms ( as was originally designed for and intended ).

For that 1% of situations, you might be able to use a LIKE type search looking for the value if it’s already known, but you run the risk of false positives, and, this will be a super slow/expensive/heavy query. If it works.

In future, there are some important pieces of information that will assist you:

  • Meta keys are not unique, you can add multiple values with the same meta key via add_post_meta, then retrieve them as an array with get_post_meta by setting the 3rd parameter to false. You don’t need serialisation for repeatable fields.
  • You don’t need serialised strings to store structured arrays. Using 3 meta key/value pairs called company_name company_id and company_address is far better than a single company meta with a serialised structure that has id name and address internal fields

I know it’s very bad practice to use serialized data for meta values, but I don’t know how to get around it – it’s how Pods works. It’s looking like I’m going to have to bin Pods and try and do this another way, but I really don’t want that to be the case…

  1. You don’t have to use Pods for everything, you can use Pods and then use an extra plugin library or manually written code
  2. Pods support and documentation might have answers for this, but 3rd party plugin support is off-topic on this site.
  3. Even if Pods cannot be changed, that doesn’t prevent you saving additional duplicated data via filters and hooks that can be queried against.
  4. Use a taxonomy for things you want to filter/query/search for. Post meta is optimised for finding key/values when you already know the post ID. Turning that upside down means the cost of the query gets big very quickly, and does not scale. It’s one of the biggest causes of slowness on WordPress sites.

Related Posts:

  1. Getting attachments by meta value
  2. WordPress altering my custom query, How to fix it?
  3. WP Meta Query for some meta (array) values
  4. How to make Meta Query case sensitive?
  5. Fetch Record based on meta key dates
  6. how to make members list directory through wordpress post custom meta key.
  7. Large AND OR query timing out
  8. How do i create a custom post query when the meta value is an array?
  9. Query against multiple locations within single custom post type post
  10. Can wp_query return posts meta in a single request?
  11. Use REGEXP in WP_Query meta_query key
  12. Meta query with string starting like pattern
  13. compare meta_query in get_posts arguments
  14. Can I query custom meta data through WP_Query
  15. meta_query where value is equal to given value
  16. querying with custom meta field with meta_query
  17. Order by meta_value_num DESC and meta_value ASC on WP 4.0
  18. What is an efficient way to query based on post_meta?
  19. WP_Query not working as expected for attachments and custom meta_query
  20. How can I create a WP_Query that returns posts where one meta_value
  21. Querying by taxonomy vs Querying by Custom fields Speed Comparison
  22. meta_query with array as value
  23. How to get sum of meta_values of a meta_key in wp_query according to conditions
  24. Order by meta_key in custom post type doesn’t affect the query
  25. meta_key and meta_value not working together
  26. Order posts by meta value and Date
  27. How add a custom posttype name using ACF field to a query post array
  28. Order Posts by meta value AND published date
  29. Get meta info related to current post
  30. Group WP_Query by meta_key date
  31. exclude posts with a specific custom field and value
  32. Performance when getting post meta for post retrieved by meta value
  33. Adding an array from a query string to a WP meta_query
  34. Get attachment by meta_key value
  35. Display custom field meta outside loop, site wide
  36. Meta_query with multiple keys and multiple values
  37. meta_query BETWEEN, but the range is stored in the custom field
  38. Extend product search with meta in WooCommerce
  39. How to list custom fields as headers and list all pages sharing that custom field under it?
  40. meta_value_num not ordering all items
  41. Query all posts if multiple meta key don’t exist
  42. meta_compare not comparing whole integer
  43. Is it possible to retrieve all posts with a certain value for metadata?
  44. Filter posts by comparing custom meta value against postdate
  45. search serialised meta_value for date value?
  46. Display posts with specific value first in query
  47. Get every post with value in meta key
  48. change order of images attached to post
  49. Order WP_Query results by meta key value in custom query
  50. Nested array issue in meta_query
  51. Order a WP_Query by meta value where the value is an array
  52. Display post meta conditionally based on it’s value
  53. Query using string from custom field as array value
  54. add_query_arg to compare and display events from a certain date
  55. Multiple meta query from array
  56. Comparing 2 Decimal Numbers from custom fields and displaying posts
  57. Query posts by searching for a string in a meta field
  58. WP_Query meta compare must include ALL array values
  59. meta_query returning excluded result
  60. meta_query weird behaviour, static int will work, but not user data
  61. Query multiple post types, but different order for each
  62. Order by the first array within a meta_query
  63. Query ACF relationship field – Comparator IN – Value array
  64. ACF: How to query for a given value count of an array like field? (e.g.: How many rows has a `flexible_content` field?)
  65. How to _GET multiple value checkbox WP_Query in Custom Toxonomy / Custom Fields
  66. wp query to use both author id and meta_query
  67. WP Query – grouping posts by same meta key, adding together values from another key
  68. Retrieve all custom field values of a specific custom field metakey as an array, inside WP_Query
  69. Meta query ignores multiple values of the key
  70. meta_query is overriding default search
  71. show most viewed post
  72. Comparing Meta Field date in WPQuery using Meta_Query?
  73. WP_User_Query Orderby Not Working
  74. Why can my filter query SOME metadata but not other metadata?
  75. Getting posts by custom field value
  76. WP_Query, ACF field and array
  77. How to set meta_query if get_post_meta returns nested array for that key? [duplicate]
  78. Order by Date Custom Field
  79. Query by meta value (add a dropdown of all values)
  80. Order Posts By Custom Field That is an array of objects
  81. Saving custom fields for WP_Query to retrieve
  82. Meta key in wp_query bug?
  83. Custom WP_query and integrating into theme file
  84. How to show all the associated posts with specific date of data metabox?
  85. WP Meta Query at depth 2
  86. Using custom field as ‘orderby’ value causing post grouping by publish date
  87. WP_Query Posts by Metadata from Option Tree
  88. Compare meta key separation
  89. Sorting Posts with meta value not working
  90. How to get several fields from wp_query?
  91. Return a single custom post from multiple meta queries
  92. Custom Search Query – include only custom fields and title
  93. query post based on comparison
  94. Sort Posts with custom meta key by default which is currently set as optional
  95. Querying meta values within an array
  96. Creating Custom Query
  97. Get posts by meta value except one post [closed]
  98. WP_Query by meta key not returning any posts
  99. How do I have multiple metaqueries inside one wordpress query
  100. Extend search query to search meta keys values based on search string
Categories wp-query Tags array, custom-field, meta-query, post-meta, wp-query
How to set Nav as a default menu in wordpress
How to pass variable from other function?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress