函数文档

the_comment()

💡 云策文档标注

概述

the_comment() 函数用于在评论循环中迭代评论索引,是 WordPress 核心函数之一。它通过调用 WP_Query::the_comment() 方法来设置当前评论。

关键要点

  • the_comment() 函数在评论循环中用于推进评论索引,以便访问下一个评论。
  • 该函数依赖于全局 $wp_query 对象,如果 $wp_query 未设置则直接返回。
  • 内部实现是调用 WP_Query::the_comment() 方法,该方法负责设置当前评论数据。
  • 此函数自 WordPress 2.2.0 版本引入,属于核心功能的一部分。

📄 原文内容

Iterate comment index in the comment loop.

Source

function the_comment() {
	global $wp_query;

	if ( ! isset( $wp_query ) ) {
		return;
	}

	$wp_query->the_comment();
}

Changelog

Version Description
2.2.0 Introduced.