钩子文档

get_the_guid

💡 云策文档标注

概述

get_the_guid 是一个 WordPress 过滤器,用于修改文章的全局唯一标识符(guid)。它允许开发者在获取 guid 时进行自定义处理,常用于 RSS 源等场景。

关键要点

  • 过滤器名称:get_the_guid
  • 参数:$post_guid(guid 字符串)和 $post_id(文章 ID)
  • 回调函数必须返回处理后的 guid,否则可能导致 RSS 源中断或其他插件错误
  • 相关函数包括 get_the_guid() 和 REST API 控制器中的准备方法
  • 自 WordPress 1.5.0 版本引入

📄 原文内容

Filters the Global Unique Identifier (guid) of the post.

Parameters

$post_guidstring
Global Unique Identifier (guid) of the post.
$post_idint
The post ID.

More Information

Note that the filter callback function must return the guid after it is finished processing, or any code using the guid (for example: RSS feeds) will break, and other plugins also filtering the guid may generate errors.

Source

return apply_filters( 'get_the_guid', $post_guid, $post_id );

Changelog

Version Description
1.5.0 Introduced.