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

Negative meta_query if storing multiple post_meta values with shared meta_key

Thats because you created the meta_query property incorrectly, it should be a multi diminsional array.

$pet_owners = new WP_Query([
    'post_type' => 'pet_owner',
    'posts_per_page' => -1,
    'meta_query' => [
        [
            'key' => 'pet',
            'value' => 'cat',
            'compare' => '!='
        ]
    ]
]);

For more information about meta_query see Custom Field (post meta) Parameters

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. Multiple meta key and value search in the query
  4. Meta compare with date (stored as string) not working
  5. How to get all term meta for a taxonomy – getting term_meta for taxonomy
  6. How metadata API works?
  7. Job of meta_key meta_value fields in database tables
  8. order by multiple meta_keys?
  9. How to get the total number of meta_values based on a custom post type?
  10. How to stop wp_postmeta from being called on archive and search pages?
  11. How can I convert postmeta from unserialized to serialized?
  12. How to create a meta_query to get all posts with a specific meta data?
  13. Compare meta_query with a Regular Expression and do a less-than operation on it
  14. $wpdb class updating meta_value using Ajax [closed]
  15. Should I save this mulit dementional arary as one post meta?
  16. How to check if a post meta key/value pair already exists for a specific post
  17. Order by meta value pro first then meta value free in my search function
  18. why after saving meta value it’s saving all the values the one that i clicked?
  19. Is it safe to add a new field to meta_value field?
  20. How can I use ‘orderby’ => ‘meta_value_num’ to order by the numerical value even if the value starts with a word?
  21. get Insert id for meta field
  22. Filter posts by meta key
  23. Display current ranking of post as a number in post title
  24. Search post overlapping dates – meta_query with meta_key
  25. How can I query for posts using a date stored in post-meta?
  26. Count Post and Page Views based on meta_value Using Shortcode in Dashboard Widget
  27. if get_post_meta function returns empty – Do Not Display HTML
  28. How to get posts by meta value as multi-dimensional array?
  29. How to get the total of two meta values from different meta keys?
  30. How to save a meta_value as a numeric value after I retrieve it via update_post_meta?
  31. How to update/add child posts meta whenever the parent post meta is updated?
  32. Combine meta query and give a specific meta query a higher priority
  33. Optimize WP Meta Query for large amount of post meta?
  34. Multiple postmeta values to the same post_id/meta_key combination?
  35. How to sort by meta value num, but ignore zero value?
  36. Retrieve posts from meta key
  37. How to show specific meta keys of all posts in admin panel?
  38. How to create a link for wordpress meta datas?
  39. How we insert values into database using metabox WordPress?
  40. Check for custom field value in different post type than current one and do something
  41. WP Query Args – search by meta_key or title
  42. Update post meta array – add new, single value
  43. SQL query based on two different custom field values
  44. How do I retrieve the slug of the current page?
  45. Most efficient way to get posts with postmeta
  46. How to only display posts whose meta_value field is not empty?
  47. Get posts by meta value
  48. Explanation of update_post_(meta/term)_cache
  49. How to extract data from a post meta serialized array?
  50. How to save an array with one metakey in postmeta?
  51. WordPress is stripping escape backslashes from JSON strings in post_meta
  52. How can I get the post ID from a WP_Query loop?
  53. Check if Post Title exists, Insert post if doesn’t, Add Incremental # to Meta if does
  54. Use REGEXP in WP_Query meta_query key
  55. How to update_post_meta value as array
  56. Adding meta tag without plugin
  57. What’s the point of get_post_meta’s $single param?
  58. What is the different between an attachment in wp_posts and an attachment in wp_postmeta?
  59. How to edit a post meta data in a Gutenberg Block?
  60. Sanitizing integer input for update_post_meta
  61. post formats – how to switch meta boxes when changing format?
  62. Execute action after post is saved with all related post_meta records (data)
  63. Lack of composite indexes for meta tables
  64. Get a single post by a unique meta value
  65. SELECT max(meta_value) FROM wp_postmeta WHERE meta_key=’price’… stops working when value is over 999
  66. if get_post_meta is empty do something
  67. How we get_post_meta without post id
  68. How get post id from meta value
  69. What is the code to get the download link for a product in WooCommerce?
  70. Safe to delete blank postmeta?
  71. Dealing with Many Meta Values, 30+
  72. advanced custom fields update_field for field type: Taxonomy
  73. update_post_meta not saving when value is zero
  74. Is it possible to orderby multiple meta_keys when using meta_value_num?
  75. Content hooks vs User hooks
  76. Getting attachments by meta value
  77. Ordering posts having multiple post-meta date fields
  78. Trying to get custom post meta through Jetpack JSON API [closed]
  79. How to update/insert custom field(post meta) data with wordpress REST API?
  80. Restrict post edit/delete based on user ID and custom field
  81. Custom Queries: Joining On Meta Values From Two Custom Post Types
  82. get_post_meta returning empty string when data shows in the database
  83. publish_post action hook doesn’t give post_meta_data
  84. Remove WordPress.org Meta link
  85. Remove post meta keys
  86. How to access the post meta of a post that has just been published?
  87. Why time functions show invalid time zone when using ‘c’ time format?
  88. Why is get_post_meta returning an array when I specify it as single?
  89. How Can I save multiple records in same meta key?
  90. How to update/delete array in post meta value?
  91. Adding an assisting editor box to Post page
  92. Meta query interfering with orderby relevance
  93. WooCommerce conditional meta query
  94. delete unused postmeta
  95. Should I sanitize custom post meta if it is going to be escaped later?
  96. How to update single value in multi dimensional Post Meta?
  97. Add post meta based on another post meta value before publish post
  98. What is an efficient way to query based on post_meta?
  99. How do I retrieve multi-dimensional arrays from the wp_postmeta table, & display on a website?
  100. Front-end update_post_meta snippet displays white screen?
Categories post-meta Tags meta-query, meta-value, post-meta
How to Save value from two inputs as array?
Is there a function to “blockify” html?

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