On this page
get_the_excerpt( int|WP_Post $post = null ): string
Retrieves the post excerpt.
Parameters
Return
string Post excerpt.
Source
File: wp-includes/post-template.php. View all references
function get_the_excerpt( $post = null ) {
if ( is_bool( $post ) ) {
_deprecated_argument( __FUNCTION__, '2.3.0' );
}
$post = get_post( $post );
if ( empty( $post ) ) {
return '';
}
if ( post_password_required( $post ) ) {
return __( 'There is no excerpt because this is a protected post.' );
}
/**
* Filters the retrieved post excerpt.
*
* @since 1.2.0
* @since 4.5.0 Introduced the `$post` parameter.
*
* @param string $post_excerpt The post excerpt.
* @param WP_Post $post Post object.
*/
return apply_filters( 'get_the_excerpt', $post->post_excerpt, $post );
}
Hooks
- apply_filters( 'get_the_excerpt',
string $post_excerpt ,WP_Post $post ) -
Filters the retrieved post excerpt.
Related
Uses
| Uses | Description |
|---|---|
| post_password_required() wp-includes/post-template.php | Determines whether the post requires password and whether a correct password has been provided. |
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| _deprecated_argument() wp-includes/functions.php | Marks a function argument as deprecated and inform when it has been used. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
| get_post() wp-includes/post.php | Retrieves post data given a post ID or post object. |
Used By
| Used By | Description |
|---|---|
| the_excerpt_embed() wp-includes/embed.php | Displays the post excerpt for the embed template. |
| WP_Posts_List_Table::column_title() wp-admin/includes/class-wp-posts-list-table.php | Handles the title column output. |
| the_excerpt_rss() wp-includes/feed.php | Displays the post excerpt for the feed. |
| the_excerpt() wp-includes/post-template.php | Displays the post excerpt. |
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_the_excerpt