钩子文档

get_the_tags

💡 云策文档标注

概述

get_the_tags 是一个 WordPress 过滤器,用于修改或过滤指定文章的标签数组。它基于 get_the_terms() 函数,允许开发者自定义标签数据。

关键要点

  • 过滤器名称:get_the_tags
  • 参数:$terms,类型为 WP_Term[]|false|WP_Error,成功时返回 WP_Term 对象数组,无标签或文章不存在时返回 false,失败时返回 WP_Error
  • 相关函数:get_the_tags() 用于检索文章标签
  • 引入版本:WordPress 2.3.0

代码示例

return apply_filters( 'get_the_tags', $terms );

📄 原文内容

Filters the array of tags for the given post.

Description

See also

Parameters

$termsWP_Term[]|false|WP_Error
Array of WP_Term objects on success, false if there are no terms or the post does not exist, WP_Error on failure.

Source

return apply_filters( 'get_the_tags', $terms );

Changelog

Version Description
2.3.0 Introduced.