get_the_excerpt()

最后更新于:2021-11-27 02:01:06

get_the_excerpt( int|GC_Post$post=null)

Retrieves the post excerpt.

参数

$post

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

Default value: null

响应

(string) Post excerpt.

源文件

文件: gc-includes/post-template.php

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 GC_Post $post         Post object.
	 */
	return apply_filters( 'get_the_excerpt', $post->post_excerpt, $post );
}