Created
October 23, 2021 00:38
-
-
Save cameronjonesweb/220708af0071526600d0a3df843eedea to your computer and use it in GitHub Desktop.
Get the excerpt of a post by ID, and generate one if not set manually
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
<?php | |
/** | |
* Get the excerpt of a post by it's ID | |
* | |
* @param int $post_id Post ID. | |
* @return string | |
*/ | |
function cameronjonesweb_get_excerpt_by_id( $post_id ) { | |
return apply_filters( 'get_the_excerpt', wp_trim_excerpt( get_post_field( 'post_excerpt', $post_id ), $post_id ), $post_id ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment