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. Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
  85. Author Page Custom Query WHERE author OR [post meta value] OR [post meta value]
  86. Two near-identical custom field types – one works, the other doesn’t . What can cause this?
  87. How to Filter Posts by Custom Fields?
  88. meta_query not working as expected
  89. Custom WP_Query for WordPress Search Results with meta_query
  90. Meta Query And/Or
  91. Is it possible to query a custom field where the value is between two fields?
  92. filter wp_query result with custom field values
  93. Retrieve all custom field values of a specific custom field metakey as an array, inside WP_Query
  94. Query for current post
  95. Meta_Query refuses to return results
  96. List users by Year of Birth using a foreach loop to dynamically populate years and data
  97. Sorting posts by meta values: 2 different orders
  98. Is there any difference between below WP_Query code snippets?
  99. Order by three custom fields (Y-m-d), then separate into yearly sections
  100. meta_query compare not doing what I want it to do
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
  • 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