get_the_excerpt

The timeline below displays how wordpress function get_the_excerpt has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.4

/**
 * Retrieves the post excerpt.
 *
 * @since 0.71
 * @since 4.5.0 Introduced the `$post` parameter.
 *
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
 * @return string Post excerpt.
 */
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);
}

WordPress Version: 4.6

/**
 * Retrieves the post excerpt.
 *
 * @since 0.71
 * @since 4.5.0 Introduced the `$post` parameter.
 *
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
 * @return string Post excerpt.
 */
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);
}

WordPress Version: 4.5

/**
 * Retrieves the post excerpt.
 *
 * @since 0.71
 * @since 4.5.0 Introduced the `$post` parameter.
 *
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
 * @return string Post excerpt.
 */
function get_the_excerpt($post = null)
{
    if (is_bool($post)) {
        _deprecated_argument(__FUNCTION__, '2.3');
    }
    $post = get_post($post);
    if (empty($post)) {
        return '';
    }
    if (post_password_required($post)) {
        return __('There is no excerpt because this is a protected post.');
    }
    /**
     * Filter 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);
}

WordPress Version: 4.0

/**
 * Retrieve the post excerpt.
 *
 * @since 0.71
 *
 * @param mixed $deprecated Not used.
 * @return string
 */
function get_the_excerpt($deprecated = '')
{
    if (!empty($deprecated)) {
        _deprecated_argument(__FUNCTION__, '2.3');
    }
    $post = get_post();
    if (empty($post)) {
        return '';
    }
    if (post_password_required()) {
        return __('There is no excerpt because this is a protected post.');
    }
    /**
     * Filter the retrieved post excerpt.
     *
     * @since 1.2.0
     *
     * @param string $post_excerpt The post excerpt.
     */
    return apply_filters('get_the_excerpt', $post->post_excerpt);
}

WordPress Version: 3.9

/**
 * Retrieve the post excerpt.
 *
 * @since 0.71
 *
 * @param mixed $deprecated Not used.
 * @return string
 */
function get_the_excerpt($deprecated = '')
{
    if (!empty($deprecated)) {
        _deprecated_argument(__FUNCTION__, '2.3');
    }
    $post = get_post();
    if (post_password_required()) {
        return __('There is no excerpt because this is a protected post.');
    }
    /**
     * Filter the retrieved post excerpt.
     *
     * @since 1.2.0
     *
     * @param string $post_excerpt The post excerpt.
     */
    return apply_filters('get_the_excerpt', $post->post_excerpt);
}

WordPress Version: 3.7

/**
 * Retrieve the post excerpt.
 *
 * @since 0.71
 *
 * @param mixed $deprecated Not used.
 * @return string
 */
function get_the_excerpt($deprecated = '')
{
    if (!empty($deprecated)) {
        _deprecated_argument(__FUNCTION__, '2.3');
    }
    $post = get_post();
    if (post_password_required()) {
        return __('There is no excerpt because this is a protected post.');
    }
    return apply_filters('get_the_excerpt', $post->post_excerpt);
}