钩子文档

the_excerpt

💡 云策文档标注

概述

the_excerpt 是一个 WordPress 过滤器,用于过滤和修改文章摘要的显示内容。它通常与 get_the_excerpt() 函数结合使用,允许开发者自定义摘要输出。

关键要点

  • the_excerpt 是一个过滤器钩子,参数为 $post_excerpt(字符串类型),表示文章摘要。
  • 核心用法示例:echo apply_filters( 'the_excerpt', get_the_excerpt() );,用于在模板中显示过滤后的摘要。
  • 相关函数包括 the_excerpt()、get_the_excerpt(),以及在 REST API 控制器中用于准备摘要响应的函数。
  • 自 WordPress 0.71 版本引入,历史悠久,是处理文章摘要显示的标准方式。

代码示例

echo apply_filters( 'the_excerpt', get_the_excerpt() );

📄 原文内容

Filters the displayed post excerpt.

Description

See also

Parameters

$post_excerptstring
The post excerpt.

Source

echo apply_filters( 'the_excerpt', get_the_excerpt() );

Changelog

Version Description
0.71 Introduced.