comments_template_query_args
云策文档标注
概述
本文档介绍了 comments_template_query_args 过滤器,用于在 comments_template() 函数中修改查询评论的参数。这些参数基于 WP_Comment_Query 类,允许开发者自定义评论查询行为。
关键要点
- 过滤器名称:comments_template_query_args
- 作用:过滤 comments_template() 中用于查询评论的参数数组
- 相关类:WP_Comment_Query,参数参考其构造函数
- 引入版本:WordPress 4.5.0
参数说明
- $comment_args:数组,包含 WP_Comment_Query 参数,如 orderby、order、status、post_id 等
- 常见参数包括:orderby(排序字段)、order(排序顺序)、status(评论状态)、post_id(文章ID)、number(评论数量)
代码示例
$comment_args = apply_filters( 'comments_template_query_args', $comment_args );
原文内容
Filters the arguments used to query comments in comments_template() .
Description
See also
Parameters
$comment_argsarray-
Array of WP_Comment_Query arguments.
orderbystring|arrayField(s) to order by.orderstringOrder of results. Accepts'ASC'or'DESC'.statusstringComment status.include_unapprovedarrayArray of IDs or email addresses whose unapproved comments will be included in results.post_idintID of the post.no_found_rowsboolWhether to refrain from querying for found rows.update_comment_meta_cacheboolWhether to prime cache for comment meta.hierarchicalbool|stringWhether to query for comments hierarchically.offsetintComment offset.numberintNumber of comments to fetch.
Source
$comment_args = apply_filters( 'comments_template_query_args', $comment_args );
Changelog
| Version | Description |
|---|---|
| 4.5.0 | Introduced. |