get_the_excerpt()

You are here:

get_the_excerpt( int|WP_Post $post = null )

Retrieves the post excerpt.

Parameters Parameters

$post

(int|WP_Post) (Optional) Post ID or WP_Post object. Default is global $post.

Default value: null


Top ↑

Return Return

(string) Post excerpt.


Top ↑

Source Source

File: wp-includes/post-template.php

406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
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 );
}


Top ↑

Changelog Changelog

Changelog
VersionDescription
4.5.0Introduced the $post parameter.
0.71Introduced.

Top ↑

Was this article helpful?
Dislike 0
Views: 2

Cart

Log in

Create an Account
Back to Top