函数文档

comment_guid()

💡 云策文档标注

概述

comment_guid() 函数用于输出当前评论的 feed GUID,基于 get_comment_guid() 获取并转义 URL。

关键要点

  • 函数输出评论的 feed GUID,适用于 RSS 或 Atom 订阅源。
  • 接受可选参数 $comment_id,可以是评论对象或 ID,默认为全局评论对象。
  • 内部调用 get_comment_guid() 获取 GUID,并使用 esc_url() 进行 URL 转义以确保安全。
  • 自 WordPress 2.5.0 版本引入,属于核心函数。

代码示例

function comment_guid( $comment_id = null ) {
    echo esc_url( get_comment_guid( $comment_id ) );
}

📄 原文内容

Displays the feed GUID for the current comment.

Parameters

$comment_idint|WP_Commentoptional
Optional comment object or ID. Defaults to global comment object.

Default:null

Source

function comment_guid( $comment_id = null ) {
	echo esc_url( get_comment_guid( $comment_id ) );
}

Changelog

Version Description
2.5.0 Introduced.