钩子文档

the_comments

💡 云策文档标注

概述

the_comments 是一个 WordPress 过滤器,用于过滤评论查询结果。它允许开发者在评论数据返回前修改或处理评论数组。

关键要点

  • 过滤器名称:the_comments
  • 参数:$_comments(WP_Comment 数组)和 $query(WP_Comment_Query 实例,通过引用传递)
  • 用途:在 WP_Comment_Query::get_comments() 中调用,用于自定义评论查询的输出
  • 引入版本:WordPress 3.1.0

代码示例

$_comments = apply_filters_ref_array( 'the_comments', array( $_comments, &$this ) );

📄 原文内容

Filters the comment query results.

Parameters

$_commentsWP_Comment[]
An array of comments.
$queryWP_Comment_Query
Current instance of WP_Comment_Query (passed by reference).

Source

$_comments = apply_filters_ref_array( 'the_comments', array( $_comments, &$this ) );

Changelog

Version Description
3.1.0 Introduced.