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
- Using meta_query, how can i filter by a custom field and order by another one?
- 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
- Querying custom post type with 2 custom fields (date-range)
- Filter a custom field based on selection of another custom field (ACF) [closed]
- How Can I save multiple records in same meta key?
- ACF Relationships in Custom Post Type Permalink
- How to sort a table of custom posts by column containing custom field
- WordPress Search documentation: how to improve search query using taxonomy terms, custom meta fields?
- 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 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()
- 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
- Filtering by Post Meta Custom Fields – Performance
- meta_query compare >= not working but
- Custom Post type and Custom Field WP_Query
- How to change post featured image using a custom field of category?
- 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?
- 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
- WP_Query order by custom field, then randomly order some of results
- 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
- How to render a custom post type template with custom fields using shortcode
- 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
- Orderby if between two meta fields
- 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
- ACF meta_key and meta_value break loop
- meta query multiple values for the same key
- Sort custom post archives by a meta value from a different custom post type?
- filter using custom fields
- 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
- Sort loop by custom field from different post type
- Meta_query by date for Events archive
- How do I display specific custom posts, and how do I edit a post’s singular page?
- Fixed custom fields depending on posttype/category
- 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