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

Querying meta values within an array

Answering my own question, as suggested in my edit I’ve had to use the following meta_query array to query the posts:

'meta_query'    => array(
    array(
        'key'       => 'country',
        'compare'   => 'LIKE',
        'value'     => '"' . get_the_ID() . '"'
    )
)

Related Posts:

  1. WP_Query orderby custom field then post_date in one query
  2. Filtering a WP_Query meta_query by numeric values isn’t working
  3. How Can I save multiple records in same meta key?
  4. Can’t sort order of wp_query with 2 meta keys
  5. Comparing timestamps in meta query doesn’t work
  6. Display two post types ordered by two custom fields
  7. Filtering by Post Meta Custom Fields – Performance
  8. WP_Query: include custom post type only with specific meta value
  9. Returning a list of custom post types excluding those without a specific meta_value
  10. Two near-identical custom field types – one works, the other doesn’t . What can cause this?
  11. wp_query check if integer exists in custom field’s array
  12. Possible to filter custom post type with multiple meta data?
  13. Query based on custom fields start and end date
  14. How to get specific post meta by title or id
  15. Getting a custom post’s custom field based on another custom post’s custom field select
  16. WP_Query of custom post type sorted by meta_key has unexpected results
  17. WP_Meta_Query object with conditionals
  18. Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
  19. Use WP_query to match post types based on custom field values
  20. Show posts from WP Custom Post Type selected from a field in a metabox
  21. Custom meta fields not showing up in WP_Response Object via custom endpoint
  22. meta query multiple values for the same key
  23. Sort custom post archives by a meta value from a different custom post type?
  24. Custom post types – meta_query: search lesson which starts sooner
  25. Meta_Query refuses to return results
  26. Query events post type after current date and timezone
  27. Selecting posts older than the current Unix epoch timestamp
  28. Custom Post Type + Custom Meta Query Not Showing 2012 Posts
  29. Check for custom field value in different post type than current one and do something
  30. WP_Query not using relation key as expected and not producing any results
  31. Setting proper query for multiple custom admin filters
  32. WP_Query orderby modified to include custom meta changes
  33. WordPress custom loop filter by meta_key and value with serialize data
  34. Display custom post type from dynamic custom field
  35. How to make Meta Query case sensitive?
  36. Meta Key Value in current-user-only loop
  37. How to check if user meta field is empty in conditional else statement
  38. Filtering custom post type on a combination of custom taxonomies and custom fields?
  39. Get posts between custom dates
  40. How to implement a Google map store locator
  41. How can I get the number of custom post type posts that have a specific attachment image set?
  42. Posting to a Custom Post Type from front end – user generated content
  43. Fetch Record based on meta key dates
  44. Update Post Meta for a logged in user
  45. Problem querying Custom post type by custom fields
  46. Orderby CPT custom fields not working
  47. WP_Query order by custom field, then randomly order some of results
  48. A better way to add a meta box to custom post types
  49. Two Custom Post Types Many to Many Relationship
  50. get_post_meta not working on publishing
  51. A method for ordering mixed dates in search result loop (theory only, no actual code)
  52. Query custom post type with ACF Date
  53. How to do WP_Query with two meta fields with orderby clause
  54. Stuck in Order by more then one
  55. Meta Query Not Returning Output Despite Having Matching Values
  56. Meta Query Filtering not working on Custom Meta Box using Radio Buttons
  57. Including metaboxes from custom post types in global search — continued
  58. How do I set all of a particular post meta to a value within the custom post type I’m in?
  59. Query Multiple Custom Posts by Custom Fields
  60. how to make members list directory through wordpress post custom meta key.
  61. Why is this query not working? (Standard posts + custom post type)
  62. Get Posts by multiple custom fields is not working
  63. WordPress request fiter order by related post’s post_title
  64. Order Custom Post Type by Custom Field Value
  65. Large AND OR query timing out
  66. Custom fields (wp_post_meta) vs Custom Table for large amount of data
  67. First custom field value (out of several) displayed twice after query
  68. Meta Query posts not showing on ending date of custom field
  69. Admin Custom Meta Box – Pull Last 5 Posts from Custom Post Type
  70. Configuring a meta query with multiple post types that have the same relationship on a single page
  71. How to Output which matched meta_keys were found from custom_type_posts?
  72. Importing Data from a Non-WordPress database, into WP
  73. filter search custom field query
  74. How to let users choose where to search for posts?
  75. Custom fields for custom post type
  76. Check if post with same meta value exists
  77. DIsplaying URL of custom field in last post of certain taxonomy && post type
  78. Is it possible to retrieve all posts with a certain value for metadata?
  79. WP Query ‘posts_per_page’
  80. Submitting Custom Post Types with custom fields from Front-end form
  81. create custom meta box with default value
  82. Display post from a date range from custom field
  83. Displaying a div from an assigned meta_value when on a page
  84. post_per_page ignored in WP_Query
  85. WP_query – Filter by tax_query and meta_query using multiple select
  86. delete_post_meta() for whole CPT / multiple posts?
  87. WP_Query orderby not work with meta_key
  88. Having Issue on Ordering CPT by Custom Field In Custom WP Query
  89. find custom post type post by searching its custom field with my string
  90. $post->post_meta not pulling any post in wordpress/php
  91. Returning a custom content types with meta values
  92. copy images from custom field to another custom field
  93. Custom Query: If One Post Object Field Value Is The Same As Another
  94. Display custom post type for specific user
  95. How to show custom field on specific custom post type posts only when filled
  96. Custom Post type loop with ACF not displaying properly
  97. Create a WP_Query where if the first value of the first row is equal to the second compare other value
  98. Cannot obtain custom meta information
  99. Group by custom field value (start and end times)
  100. How can I output WPAlchemy repeating fields meta values in my page template?
Categories custom-post-types Tags custom-field, custom-post-types, meta-query, post-meta, wp-query
How to solve the fopen error?
Pagination doesn’t work for home page custom post type query

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