функция
since 4.5.0
get_the_excerpt()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
get_the_excerpt( int|WP_Post|null $post = null ): string
Описание
Получает отрывок записи.
Параметры
$post
int|WP_Post|null
необязательный
= null
ID записи или объект WP_Post. По умолчанию — глобальная переменная $post.
Возвращаемое значение
string
Исходный код
wp-includes/post-template.php:413
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 );
}
История изменений
| Версия | Описание |
|---|---|
| 4.5.0 | Introduced the $post parameter. |
| 0.71 | Introduced. |

