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

Multiple meta key and value search in the query

You don’t have any conditions for “any” as a given value in your code, so it won’t be treated as any, but as “any”.

But your code checks if given value is not empty, so passing it like so should work:

api.php?key=fruit,drink&value=,whiskey

PS. I’m not sure if that’s the best way of passing arguments to your api 😉

Related Posts:

  1. WP_POSTMETA – What do these values mean inside the data structure?
  2. I can not display meta value in extras.php and template-tags.php
  3. Negative meta_query if storing multiple post_meta values with shared meta_key
  4. How to get posts by meta value as multi-dimensional array?
  5. How to extract data from a post meta serialized array?
  6. Meta compare with date (stored as string) not working
  7. How to get all term meta for a taxonomy – getting term_meta for taxonomy
  8. How to update single value in multi dimensional Post Meta?
  9. How to store post meta in an array?
  10. WP Meta Query for some meta (array) values
  11. How metadata API works?
  12. Job of meta_key meta_value fields in database tables
  13. order by multiple meta_keys?
  14. How to get the total number of meta_values based on a custom post type?
  15. How to stop wp_postmeta from being called on archive and search pages?
  16. get_*_meta doesn’t always return an array
  17. Run a check for multiple meta key values
  18. Unset field from an array not working as expected
  19. How can I convert postmeta from unserialized to serialized?
  20. How to create a meta_query to get all posts with a specific meta data?
  21. Compare meta_query with a Regular Expression and do a less-than operation on it
  22. $wpdb class updating meta_value using Ajax [closed]
  23. Post meta as array looks like string instead of array
  24. Grouping posts by a custom meta value
  25. Time & Date on Post – Time Ago Custom Function
  26. Should I save this mulit dementional arary as one post meta?
  27. How to check if a post meta key/value pair already exists for a specific post
  28. Can A Post Meta Field Store multiple values that are not in an array?
  29. Order by meta value pro first then meta value free in my search function
  30. why after saving meta value it’s saving all the values the one that i clicked?
  31. change order of images attached to post
  32. Print specific values stored in a post meta array
  33. Is it safe to add a new field to meta_value field?
  34. How can I use ‘orderby’ => ‘meta_value_num’ to order by the numerical value even if the value starts with a word?
  35. Array of user ids to list of user names
  36. get Insert id for meta field
  37. Filter posts by meta key
  38. Display current ranking of post as a number in post title
  39. Search post overlapping dates – meta_query with meta_key
  40. How can I query for posts using a date stored in post-meta?
  41. update_post_meta() updating nested array in Multidimensional array with empty sub-array
  42. Count Post and Page Views based on meta_value Using Shortcode in Dashboard Widget
  43. How can I update this array built from post meta data?
  44. What format is this and how to get value “lal” and “pila” from it
  45. if get_post_meta function returns empty – Do Not Display HTML
  46. Trouble with serialized metadata
  47. How to get the total of two meta values from different meta keys?
  48. How to save a meta_value as a numeric value after I retrieve it via update_post_meta?
  49. How to update/add child posts meta whenever the parent post meta is updated?
  50. Combine meta query and give a specific meta query a higher priority
  51. WordPress meta query with meta serialized data array value
  52. Reading Content in an Array as it relates to a meta_query
  53. Optimize WP Meta Query for large amount of post meta?
  54. Multiple postmeta values to the same post_id/meta_key combination?
  55. How to sort by meta value num, but ignore zero value?
  56. Plugin Shortcode value in post
  57. Retrieve posts from meta key
  58. Fetching array of postmeta with $wpdb and in_array conditional
  59. How to show specific meta keys of all posts in admin panel?
  60. How to create a link for wordpress meta datas?
  61. wp_postmeta store multiple values in one key [closed]
  62. How we insert values into database using metabox WordPress?
  63. Check for custom field value in different post type than current one and do something
  64. WP Query Args – search by meta_key or title
  65. Update post meta array – add new, single value
  66. SQL query based on two different custom field values
  67. How do I retrieve the slug of the current page?
  68. Most efficient way to get posts with postmeta
  69. How to only display posts whose meta_value field is not empty?
  70. Get posts by meta value
  71. Explanation of update_post_(meta/term)_cache
  72. How to save an array with one metakey in postmeta?
  73. WordPress is stripping escape backslashes from JSON strings in post_meta
  74. How can I get the post ID from a WP_Query loop?
  75. Check if Post Title exists, Insert post if doesn’t, Add Incremental # to Meta if does
  76. Use REGEXP in WP_Query meta_query key
  77. How to update_post_meta value as array
  78. Adding meta tag without plugin
  79. What’s the point of get_post_meta’s $single param?
  80. What is the different between an attachment in wp_posts and an attachment in wp_postmeta?
  81. How to edit a post meta data in a Gutenberg Block?
  82. Sanitizing integer input for update_post_meta
  83. post formats – how to switch meta boxes when changing format?
  84. Execute action after post is saved with all related post_meta records (data)
  85. Lack of composite indexes for meta tables
  86. Can I query custom meta data through WP_Query
  87. Get a single post by a unique meta value
  88. SELECT max(meta_value) FROM wp_postmeta WHERE meta_key=’price’… stops working when value is over 999
  89. if get_post_meta is empty do something
  90. How we get_post_meta without post id
  91. How get post id from meta value
  92. What is the code to get the download link for a product in WooCommerce?
  93. Safe to delete blank postmeta?
  94. Dealing with Many Meta Values, 30+
  95. advanced custom fields update_field for field type: Taxonomy
  96. update_post_meta not saving when value is zero
  97. Is it possible to orderby multiple meta_keys when using meta_value_num?
  98. Content hooks vs User hooks
  99. Getting attachments by meta value
  100. When using add_post_meta and update_post_meta, is there any way to give the individual arrays keys?
Categories post-meta Tags array, meta-query, meta-value, post-meta
WordPress numeric (yearly) page names / disable yearly archives
Shortcode not interpreted if parameter set

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