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

How to make Meta Query case sensitive?

This is how meta_key/_values work. How you store your values is case sensitive.

Example meta_key = "foo' and meta_value="Bar"

Would return the result you are looking for:

$posts = new WP_Query( 'post_type=post&meta_key=foo&meta_value=Bar' );

Would not return the result you are looking for:

$posts = new WP_Query( 'post_type=post&meta_key=foo&meta_value=bar' );

However it does appear that your database can be setup as case insinsitive and cause some issues.

Please note that if your database collation is case insensitive (has with suffix _ci) then update_post_meta and delete_post_meta and get_posts will update/delete/query the meta records with keys that are upper or lower case. However get_post_meta will apparently be case sensitive due to WordPress caching. See https://core.trac.wordpress.org/ticket/18210 for more info.

Reference: update_post_meta for more info

Related Posts:

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

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
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 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