Created
July 19, 2017 03:41
-
-
Save gopperman/801c3d55e38bae6a28f3ecfcfb6b8d60 to your computer and use it in GitHub Desktop.
Add a custom meta field to wordpress API response
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
function my_rest_prepare_post( $data, $post, $request ) { | |
$_data = $data->data; | |
$_data['URL'] = get_post_meta( $post->ID, 'URL', true ); | |
$data->data = $_data; | |
return $data; | |
} | |
add_filter( 'rest_prepare_post', 'my_rest_prepare_post', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment