Sorry, my solution was only for a GET request. I haven’t tried to use a POST request, but I’m pretty sure there’s an easy way to do it. Have you looked at update_field before?
Figured it out. The correct hook is json_prepare_post
.
<?
add_filter('json_prepare_post', 'json_api_encode_acf');
function json_api_encode_acf($post) {
$acf = get_fields($post['ID']);
if (isset($post)) {
$post['acf'] = $acf;
}
return $post;
}
?>
The way this got solved for the JSON API plugin was through this…
http://stackoverflow.com/questions/10132685/json-api-to-show-advanced-custom-fields-wordpress
…which uses a hook specific to that plugin. For the WP-API function, it looks like maybe wp_json_server_before_serve
is the thing to hook into?