-
-
Save yoren/7bfff84640ec6288deac to your computer and use it in GitHub Desktop.
Display Post Excerpt To The More Tag With WP API V2
This file contains 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 | |
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 ); |
This file contains 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 | |
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 ); |
This file contains 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 | |
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