Skip to content

Instantly share code, notes, and snippets.

@adriancbo
Forked from rileypaulsen/functions.php
Created September 1, 2014 21:33
Show Gist options
  • Save adriancbo/d897f6b85de392b7e3e0 to your computer and use it in GitHub Desktop.
Save adriancbo/d897f6b85de392b7e3e0 to your computer and use it in GitHub Desktop.
Add Advanced Custom Fields Fields to the WP REST API - Awesome!
function wp_api_encode_acf($data,$post,$context){
$data['meta'] = array_merge($data['meta'],get_fields($post['ID']));
return $data;
}
if( function_exists('get_fields') ){
add_filter('json_prepare_post', 'wp_api_encode_acf', 10, 3);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment