Created
December 3, 2014 16:16
-
-
Save jeffcdavis/31a907399e34827a4248 to your computer and use it in GitHub Desktop.
Add meta data to WP-API custom post type without authorization (example here is for Tribe Events Calendar)
This file contains hidden or 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
<?php | |
add_filter( 'json_prepare_post', function ($data, $post, $context) { | |
$data['myextradata'] = array( | |
'start_date' => get_post_meta( $post['ID'], '_EventStartDate', true ), | |
'end_date' => get_post_meta( $post['ID'], '_EventEndDate', true ), | |
); | |
return $data; | |
}, 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment