Skip to content

Instantly share code, notes, and snippets.

@yoren yoren/functions-1.php Secret
Last active Mar 13, 2017

Embed
What would you like to do?
Display Post Excerpt To The More Tag With WP API V2
<?php
function my_rest_prepare_post( $data, $post, $request ) {
$_data = $data->data;
$excerpt = get_extended( $post->post_content );
$_data['my_excerpt'] = $excerpt['main'];
$data->data = $_data;
return $data;
}
add_filter( 'rest_prepare_post', 'my_rest_prepare_post', 10, 3 );
<?php
function my_rest_prepare_post( $data, $post, $request ) {
$_data = $data->data;
$excerpt = get_extended( apply_filters( 'the_content', $post->post_content ) );
$_data['my_excerpt'] = $excerpt['main'];
$data->data = $_data;
return $data;
}
add_filter( 'rest_prepare_post', 'my_rest_prepare_post', 10, 3 );
<?php
function my_rest_prepare_post( $data, $post, $request ) {
$_data = $data->data;
$excerpt = get_the_content();
$_data['my_excerpt'] = $excerpt;
$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.