Skip to content

Instantly share code, notes, and snippets.

@romuloctba
Created September 24, 2014 04:33
Show Gist options
  • Save romuloctba/7c6182a0b01d241c4503 to your computer and use it in GitHub Desktop.
Save romuloctba/7c6182a0b01d241c4503 to your computer and use it in GitHub Desktop.
Add all custom fields to JSON REST API wordpress
function json_api_prepare_post( $post_response, $post, $context ) {
$field = get_post_custom($post['ID']);
$post_response['custom-fields'] = $field;
return $post_response;
}
add_filter( 'json_prepare_post', 'json_api_prepare_post', 10, 3 );
@romuloctba
Copy link
Author

But I'm pretty sure there's another (and waaaaay better coded) plugin that can do this for you, with a better UI too. This code I wrote for myself long time ago , I'm kindda ashamed of showing it up today :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment