Skip to content

Instantly share code, notes, and snippets.

@yoren yoren/functions.php Secret
Created Mar 19, 2016

What would you like to do?
Remove Content From WP API Response When Listing Posts
function my_rest_prepare_post( $data, $post, $request ) {
$_data = $data->data;
$params = $request->get_params();
if ( ! isset( $params['id'] ) ) {
unset( $_data['content'] );
$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
You can’t perform that action at this time.