Based on https://stackoverflow.com/questions/42011047/wordpress-query-by-acf-relationship-field, I was able to fix this by changing the 'compare' => 'IN'
to 'compare' => 'LIKE'
. So the resultant code looks like this:
$new_query_args = [
'meta_query' => [
[
'key' => 'af_author',
'value' => get_the_ID(),
'compare' => 'LIKE',
]
]
];
$query_args = array_merge( $query_args, $new_query_args );
I’m not exactly sure why this works, but it fixed the problem.
Related Posts:
- Filtering a WP_Query meta_query by numeric values isn’t working
- Meta Query Not Returning Output Despite Having Matching Values
- Query based on custom fields start and end date
- meta_query for keys that aren’t yet set
- WP_Query orderby custom field then post_date in one query
- Automatically fill custom field value on post publish/update
- Filter a custom field based on selection of another custom field (ACF) [closed]
- ACF Relationships in Custom Post Type Permalink
- How to sort a table of custom posts by column containing custom field
- order by meta_value serialized array
- Meta Query “IN” doesn’t work with ACF checkbox filter
- Use Custom Post Type as Custom Field
- Comparing timestamps in meta query doesn’t work
- Display two post types ordered by two custom fields
- How loop through posts based on custom fields
- Display custom post types with custom date field value (before today) & order by custom date field
- Get Custom Field Values by Another Custom Field in WordPress
- How to Display ACF Relationship Custom Field as Link to Specific Custom Post?
- Query Custom Post Types by date (custom field) range
- meta_query compare >= not working but
- Custom Post type and Custom Field WP_Query
- WP_Query: include custom post type only with specific meta value
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- Retrieve value of a category’s custom field
- wp_query check if integer exists in custom field’s array
- How can I dynamically add a post to a custom post type which uses a custom field?
- Filtering custom post type on a combination of custom taxonomies and custom fields?
- Bulk Update Custom Fields for Custom Post Types
- Query custom post type with ACF Date
- Stuck in Order by more then one
- Meta Query Filtering not working on Custom Meta Box using Radio Buttons
- ACF From & To Date Validations
- Using advanced custom fields from one custom post type in another custom post type / using nested shortcodes
- Order Custom Post Type by Custom Field Value
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- Meta Query posts not showing on ending date of custom field
- Admin Custom Meta Box – Pull Last 5 Posts from Custom Post Type
- How to Output which matched meta_keys were found from custom_type_posts?
- Multiple Frontend Filters Using Advanced Custom Fields
- Integrate Custom Post Type Events into Calendar
- Possible to filter custom post type with multiple meta data?
- Displaying custom field according to date
- filter search custom field query
- How to let users choose where to search for posts?
- WebP Fallback for Inline Background Image in Style Attribute
- How to get a custom type post data when it has a connection with another custom type post?
- List of users that clicked a ‘Join’ button at single post
- Getting a custom post’s custom field based on another custom post’s custom field select
- How to inherit field value from parent post into in child / sub post
- Custome fields not displayed
- Custom Query: If One Post Object Field Value Is The Same As Another
- posttype and custom fields on multisite
- How do I get_the_postID() for a custom post that uses ACF repeater field?
- How do I replace the post title with a custom field?
- Sum and count of custom field values
- Group by custom field value (start and end times)
- Custom post types, disable fields
- Get A Custom Field From A Custom Taxonomy Of A Custom Post Type [closed]
- Using WP meta query to show custom post types by a start and finish date
- Excerpt length: get first paragraph
- Having a repeating custom field in admin custom post type, what I’d go better with, for DB’s sake? ACF repeater or query a different post type?
- order the meta query results by 2 custom fields
- ACF – Retrieve custom taxonomy from a relationship field
- Create if else for post types in WP_Query ‘post__in’ values
- Using OR relation in meta_query to check for a value before sorting by another
- Filter result of Custom Post Type using meta_query with ACF
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- Query posts by current ACF meta key value on single page as related posts
- Meta query and compare “!=” not working as expected
- Display Custom Field or Custom Taxonomy in front page /post/product
- How to access repeater field of a custom field?
- Filter posts by their related field’s custom field
- Show posts from WP Custom Post Type selected from a field in a metabox
- 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
- Autofill advanced custom field with user data
- Advanced search form with multiple custom fields
- Meta_Query refuses to return results
- How do I display specific custom posts, and how do I edit a post’s singular page?
- Automatically convert standard posts with custom fields to custom post types
- Query events post type after current date and timezone
- Can’t pick up a field created with Advanced Custom Fields
- Get month and day from a Date Picker custom field
- Selecting posts older than the current Unix epoch timestamp
- Unable to get the upcoming events for custom post
- Setting a custom $query->query_vars[‘meta_key’] breaks the WordPress menu
- If i have custom post type with 5 custom fields do i have to create a new loop to reference each one?
- How to show animal lineage/pedigree in WordPress?
- WP_Query arguments: Loop through custom post type – get all entries except excluded meta_key?
- loop through custom post-type with two meta_keys
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- ACF – Query relationship without ID
- Get Posts ordered by a date custom meta field
- Check for custom field value in different post type than current one and do something
- Is it possible to specify a time interval (from, to) in ACF with date picker, or other custom field?
- Function to Compare CPT Post Custom Value with Default Posts CF Value
- Display ACF object field data using Elementor Custom Query
- Post object GUID adding http:/
- WP_Query not using relation key as expected and not producing any results