Skip to content

Instantly share code, notes, and snippets.

@modemlooper
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save modemlooper/912325bc95e3ed2ce6b2 to your computer and use it in GitHub Desktop.
Save modemlooper/912325bc95e3ed2ce6b2 to your computer and use it in GitHub Desktop.
add meta to api
function custom_json_api_prepare_post( $post_response, $post, $context ) {
$post_response['do_api_action']['above_title'] = 'this is above the title';
$post_response['do_api_action']['below_title'] = 'this is below the title';
$post_response['do_api_action']['above_content'] = 'this is above the content';
$post_response['do_api_action']['below_content'] = 'this is below the content';
if( 1842 === $post['ID'] ) {
$post_response['do_api_action']['above_title'] = 'this is above the title on post 1842';
}
return $post_response;
}
add_filter( 'json_prepare_post', 'custom_json_api_prepare_post', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment