钩子文档

comments_clauses

💡 云策文档标注

概述

comments_clauses 是一个 WordPress 过滤器,用于修改评论查询的 SQL 子句。它允许开发者在执行 WP_Comment_Query 时自定义 SELECT、JOIN、WHERE 等查询部分。

关键要点

  • 过滤器名称:comments_clauses
  • 参数:$clauses(关联数组,包含查询子句如 fields、join、where、orderby、limits、groupby)和 $query(WP_Comment_Query 实例,通过引用传递)
  • 用途:在 WP_Comment_Query::get_comment_ids() 内部使用,以获取匹配查询变量的评论 ID 列表
  • 引入版本:WordPress 3.1.0

代码示例

$clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $pieces ), &$this ) );

📄 原文内容

Filters the comment query clauses.

Parameters

$clausesstring[]
Associative array of the clauses for the query.

  • fields string
    The SELECT clause of the query.
  • join string
    The JOIN clause of the query.
  • where string
    The WHERE clause of the query.
  • orderby string
    The ORDER BY clause of the query.
  • limits string
    The LIMIT clause of the query.
  • groupby string
    The GROUP BY clause of the query.

$queryWP_Comment_Query
Current instance of WP_Comment_Query (passed by reference).

Source

$clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $pieces ), &$this ) );

Changelog

Version Description
3.1.0 Introduced.