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:
- WP_Query orderby custom field then post_date in one query
- Filtering a WP_Query meta_query by numeric values isn’t working
- How Can I save multiple records in same meta key?
- Can’t sort order of wp_query with 2 meta keys
- Comparing timestamps in meta query doesn’t work
- Display two post types ordered by two custom fields
- Filtering by Post Meta Custom Fields – Performance
- WP_Query: include custom post type only with specific meta value
- Returning a list of custom post types excluding those without a specific meta_value
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- wp_query check if integer exists in custom field’s array
- Possible to filter custom post type with multiple meta data?
- Query based on custom fields start and end date
- How to get specific post meta by title or id
- Getting a custom post’s custom field based on another custom post’s custom field select
- WP_Query of custom post type sorted by meta_key has unexpected results
- WP_Meta_Query object with conditionals
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- Use WP_query to match post types based on custom field values
- Show posts from WP Custom Post Type selected from a field in a metabox
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- meta query multiple values for the same key
- Sort custom post archives by a meta value from a different custom post type?
- Custom post types – meta_query: search lesson which starts sooner
- Meta_Query refuses to return results
- Query events post type after current date and timezone
- Selecting posts older than the current Unix epoch timestamp
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- Check for custom field value in different post type than current one and do something
- Query all posts where a meta key does not exist
- Using meta_query, how can i filter by a custom field and order by another one?
- Mixing regular and custom post types (with meta_query) on home page
- Admin Area Custom Type Search By Meta Fields Without Title & Content
- how to filter by last name for custom post
- Querying custom post type with 2 custom fields (date-range)
- Detect meta value changes when post is updated (post_updated)
- Search everything (posts, pages, tags, cpt, meta)
- Using Query Posts With Multiple Post Types And A Taxonomy
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- How to get source of custom meta image?
- Query for posts from any post type but only add instock products
- Get post info inside modal window?
- query order by date on custom type: wrong order
- Displaying Meta Box Image
- Having trouble with custom date field for CPT query (WordPress)
- Display posts if a custom field value is equal to another custom field value
- ACF Upload Image in repeater from front-end with custom form? – add_post_meta()
- WP Query—Relationship between two custom post types and their fields
- Custom Post type and Custom Field WP_Query
- Populate Custom Fields in a Custom Post Type?
- Setting proper query for multiple custom admin filters
- WP_Query orderby modified to include custom meta changes
- How to make Meta Query case sensitive?
- How to check if user meta field is empty in conditional else statement
- Get posts between custom dates
- WP_Query order by custom field, then randomly order some of results
- A better way to add a meta box to custom post types
- A method for ordering mixed dates in search result loop (theory only, no actual code)
- How to do WP_Query with two meta fields with orderby clause
- How do I set all of a particular post meta to a value within the custom post type I’m in?
- Get Posts by multiple custom fields is not working
- Large AND OR query timing out
- filter search custom field query
- Submitting Custom Post Types with custom fields from Front-end form
- Display post from a date range from custom field
- Displaying a div from an assigned meta_value when on a page
- post_per_page ignored in WP_Query
- Display custom post type for specific user
- How to show custom field on specific custom post type posts only when filled
- Query Posts, order by meta value
- Two queries – one with checkbox ticked, one without – comparing meta_query
- WP query_posts group by meta field related
- Create if else for post types in WP_Query ‘post__in’ values
- WP Query from two Custom Post type fields as statement
- Using OR relation in meta_query to check for a value before sorting by another
- Trouble with serialized metadata
- How to keep custom post type related information
- Orderby if between two meta fields
- How to sort by multiple values in a nested WP_Query
- How can I fetch all the dates from custom fields from various different custom post types and show / list them at one place in ascending order?
- Where is get_post_meta value located?
- Query against multiple locations within single custom post type post
- post type => ‘any’ not applied my custom queries
- How to get the posts that my following users are liked?
- Sort loop by custom field from different post type
- Meta_query by date for Events archive
- Add more custom fields when creating a new custom post type
- How can I get the $key / $value pairs of custom fields that were added via 3rd party plugins or themes?
- meta query always fails even if data is correct
- Calling specific page with wp query
- Values inside a custom field to determine which category posts to display
- WP_Query get posts where post_name is empty
- Trying to combine multiple WordPress queries
- Advanced search form with filters for custom taxonomies and custom fields
- Query recent posts by author
- Filter Custom post type by another Custom post type
- Function to Compare CPT Post Custom Value with Default Posts CF Value
- Display ACF object field data using Elementor Custom Query
- WordPress custom field sorting, weird behavior: the latest post is at the end
- Sort CPT by taxonomy AND THEN by custom field