Created
September 24, 2014 04:33
-
-
Save romuloctba/7c6182a0b01d241c4503 to your computer and use it in GitHub Desktop.
Add all custom fields to JSON REST API wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); |
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
Adiciona todos os custom fields do post ao API REST JSON
Atenção: São adicionados tb os campos "_edit_last" e "_edit_lock"
Adicionar ao final do functions.php do seu tema