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. How to only display posts whose meta_value field is not empty?
  44. Check if Post Title exists, Insert post if doesn’t, Add Incremental # to Meta if does
  45. How to update/insert custom field(post meta) data with wordpress REST API?
  46. Custom Queries: Joining On Meta Values From Two Custom Post Types
  47. Front-end update_post_meta snippet displays white screen?
  48. WordPress Admin Panel search posts with custom post meta values along with title
  49. Get post from meta_key and meta_value
  50. get_post_meta returns bool(false)
  51. How to get custom post type to display post meta on archive pages?
  52. How to use post_id with a Class?
  53. Query metas (and not : query posts by metas)
  54. Set default Custom Post Meta Value
  55. INSERT ON DUPLICATE KEY UPDATE failes in postmeta table
  56. Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
  57. Set Checkbox as checked by default
  58. Query multiple meta values
  59. replacing the_autor or make callback
  60. Some post meta fields stop saving after a few successful saves
  61. Save an array of values in the post meta box
  62. get_post_meta() empty in preview WHEN custom post is published [closed]
  63. Permalink structure with $_SESSION variables
  64. get_post_meta not extracting title,permalink and posttype
  65. WordPress Screwing Up ‘orderby’ => ‘meta_value_num’ in ‘pre_get_posts’
  66. Query posts according to specific post meta values
  67. Save post meta foreach loop
  68. Remove last character in get_post_meta
  69. mass delete posts based on metadata
  70. Duplicate rows in meta table, any known relations in WC?
  71. Adding Custom MetaData
  72. Suggestion to make posts have multiple associated items
  73. update_post_meta in loop changing ALL values
  74. Why is my get_post_meta not properly calling the custom field when attempting to embed a YouTube video?
  75. Nested array issue in meta_query
  76. How to echo value of a meta select box to the browser
  77. WP_Meta_Query object with conditionals
  78. How do I add a fixed value to get_post_meta();?
  79. Add post’s category as a meta tag to the post
  80. Is duplicate `_wp_attachment_image_alt` meta key allowed?
  81. How do I list taxonomies that have upcoming events in WP? Is there a way to do this without having to query posts first?
  82. Strict comparisons problem when using boolean post meta
  83. Why is the actual number of thumbnail images not matching what is store in an attachments metadata?
  84. How to use multiple Meta Field from CPT as Post permalink
  85. Set class if a meta value is set within post archive
  86. show most viewed post
  87. Get table parameter and save in meta value
  88. How can i show post views using specified post ID?
  89. How to add/update post meta to use in query?
  90. Is there any way to get all custom posts and all custom terms with it’s meta in few queries?
  91. Move Entry Meta Above Title in Archives (Genesis + Brunch Pro)
  92. Exclude category from DB query
  93. Update event post meta each day automaticaly
  94. Advanced Custom Field — grabbing post_meta from previous post
  95. Fetch post meta data on POST request
  96. Which query method to use? (edit- wpdb syntax problems)
  97. How to update post meta with xml data
  98. wp_postmeta store multiple values in one key [closed]
  99. get Custom field label (select/dropdown) on front end
  100. Hide individual page title using checkbox in custom meta box?
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
  • 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