I’ve been trying for days to do this, including consulting AI’s through hundreds of chats and just cannot get results.
I’m trying to use the API to create a post within a CPT of Archetypes and also populate the custom fields with text. The only thing I’ve achieved is to make the post. The custom fields never populate.
Looking around the net I can see this has been an issue with many other people with no solutions posted. And yes, I’ve enabled to ‘show in REST API’.
I have same problem, added custom fields to media file, filled it an no data shows in wp-json/wp/v2/media/
Any idea ?
I manage to trace issue to code
//Filter results.
if ( $filter && $posts ) {
var_dump($filter);
return $this->filter_posts( $posts, $filter );
In the file class-acf-internal-post-type.php, within the get_posts function, I believe the post_id used in the filter is invalid, as it points to a media post ID rather than an ACF post. I don’t know the internals of ACF, but after removing it, the ACF values appeared in the JSON API. However, this may break other things.
Edit: there is invalid code in get_field_groups_by_id in rest api,
default case is invalid, and does not check for attachement sub type.
default:
$args = $object_sub_type === “attachment” ? array( ‘attachment’ => $object_id ): array( ‘post_id’ => $object_id );