描述:
获取当前文章的摘要
用法:
<?php $excerpt = get_the_excerpt( $deprecated ) ?>
示例:
<?php
$my_excerpt = get_the_excerpt();
if ( '' != $my_excerpt ) {
// Some string manipulation performed
}
echo $my_excerpt; // Outputs the processed value to the page
?>
源文件:
/**
* 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 );
}