Last active
August 29, 2015 14:09
-
-
Save modemlooper/912325bc95e3ed2ce6b2 to your computer and use it in GitHub Desktop.
add meta to api
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 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