How do you return select fields within a field group with rest API? I’ve activated the Show in REST API toggle in the group and the fields show fine at /wp-json/wp/v2/posts. However, when I try to limit what fields show then nothing gets returned. Many of the ACF fields are not needed for the json file so I’d like to limit what is actually pulled. I’m using the following code, which is found in the ACF documentation. I must be doing something wrong.
add_filter( 'acf/rest/get_fields', function ( $fields, $resource, $http_method ) {
// Modify and return the $fields array here.
if ( $http_method == 'GET' && $resource['type'] == 'post' ) {
return wp_list_filter( $fields, [ 'title' => 'title' ] );
}
return $fields;
}, 10, 3 );