钩子文档

get_page_of_comment_query_args

💡 云策文档标注

概述

本文档介绍 WordPress 中的 get_page_of_comment_query_args 过滤器,用于在 get_page_of_comment() 函数中修改查询评论的参数。开发者可以通过此过滤器自定义评论查询行为,如限制评论类型或状态。

关键要点

  • 过滤器名称:get_page_of_comment_query_args,应用于 get_page_of_comment() 函数中的评论查询参数。
  • 参数:$comment_args 数组,包含 WP_Comment_Query 参数,如 type、post_id、status、date_query 等,用于控制评论查询的各个方面。
  • 用途:允许开发者过滤和调整评论分页查询,例如基于评论类型、状态或日期进行自定义筛选。

代码示例

$comment_args = apply_filters( 'get_page_of_comment_query_args', $comment_args );

注意事项

  • 此过滤器自 WordPress 5.5.0 版本引入,使用时需确保版本兼容性。
  • 参数 $comment_args 是一个数组,可包含 WP_Comment_Query 构造函数支持的所有选项,如 fields、count、parent 等。
  • 相关函数:get_page_of_comment(),用于计算评论在分页中的页码位置。

📄 原文内容

Filters the arguments used to query comments in get_page_of_comment() .

Description

See also

Parameters

$comment_argsarray
Array of WP_Comment_Query arguments.

  • type string
    Limit paginated comments to those matching a given type.
    Accepts 'comment', 'trackback', 'pingback', 'pings' (trackbacks and pingbacks), or 'all'. Default 'all'.
  • post_id int
    ID of the post.
  • fields string
    Comment fields to return.
  • count bool
    Whether to return a comment count (true) or array of comment objects (false).
  • status string
    Comment status.
  • parent int
    Parent ID of comment to retrieve children of.
  • date_query array
    Date query clauses to limit comments by. See WP_Date_Query.
  • include_unapproved array
    Array of IDs or email addresses whose unapproved comments will be included in paginated comments.

Source

$comment_args = apply_filters( 'get_page_of_comment_query_args', $comment_args );

Changelog

Version Description
5.5.0 Introduced.