Last active
June 1, 2017 11:18
-
-
Save daliborgogic/5cbdd68114d2b2a46ac5 to your computer and use it in GitHub Desktop.
WP REST API v2
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
// WP REST API v2 | |
// Prepare Pages | |
add_filter('rest_prepare_page', 'remove_extra_data', 12, 3); | |
function remove_extra_data($data, $post, $context) { | |
if ($context !== 'view' || is_wp_error ($data)) { | |
unset ($data->data['excerpt']); | |
// ... | |
return $data; | |
} | |
} | |
// Prepare Posts | |
add_filter('rest_prepare_post', 'remove_extra_data', 12, 3); | |
function remove_extra_data($data, $post, $context) { | |
if ($context !== 'view' || is_wp_error($data)) { | |
unset($data->data['excerpt']); | |
// ... | |
return $data; | |
} | |
} | |
// For Custom Post Type: add_filter('rest_prepare_{$post_type}', 'remove_extra_data', 12, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment