get_the_excerpt
apply_filters( ‘get_the_excerpt’, string $post_excerpt , WP_Post $post )
过滤钩子:过滤检索到的文章摘要。
Filter Hook: Filters the retrieved post excerpt.
参数(Parameters)
参数 | 类型 | 说明 |
---|---|---|
$post_excerpt | (string) | 文章节选。 |
$post | (WP_Post) | Post对象。 |
源码(Source)
/** * 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 ); }
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
4.5.0 | wp-includes/post-template.php:427 | 3 | 0 |
笔记(Notes)
对存储在变量中的字符串使用此筛选器时,该字符串将不会被“摘录长度”筛选器修剪。
get_the_excerpt 为WP2原创文章,链接:https://www.wp2.cn/hook/get_the_excerpt-2/