comments_template_top_level_query_args
Filter HookDescription
Filters the arguments used in the top level comments query. }Hook Information
File Location |
wp-includes/comment-template.php
View on GitHub
|
Hook Type | Filter |
Line Number | 1528 |
Hook Parameters
Type | Name | Description |
---|---|---|
array
|
$top_level_args
|
{ The top level query arguments for the comments template. |
Usage Examples
Basic Usage
<?php
// Hook into comments_template_top_level_query_args
add_filter('comments_template_top_level_query_args', 'my_custom_filter', 10, 1);
function my_custom_filter($top_level_args) {
// Your custom filtering logic here
return $top_level_args;
}
Source Code Context
wp-includes/comment-template.php:1528
- How this hook is used in WordPress core
<?php
1523 * @type string|array $orderby The field(s) to order by.
1524 * @type int $post_id The post ID.
1525 * @type string|array $status The comment status to limit results by.
1526 * }
1527 */
1528 $top_level_args = apply_filters( 'comments_template_top_level_query_args', $top_level_args );
1529
1530 $top_level_count = $top_level_query->query( $top_level_args );
1531
1532 $comment_args['offset'] = ( (int) ceil( $top_level_count / $per_page ) - 1 ) * $per_page;
1533 }
PHP Documentation
<?php
/**
* Filters the arguments used in the top level comments query.
*
* @since 5.6.0
*
* @see WP_Comment_Query::__construct()
*
* @param array $top_level_args {
* The top level query arguments for the comments template.
*
* @type bool $count Whether to return a comment count.
* @type string|array $orderby The field(s) to order by.
* @type int $post_id The post ID.
* @type string|array $status The comment status to limit results by.
* }
*/
Quick Info
- Hook Type: Filter
- Parameters: 1
- File: wp-includes/comment-template.php
Related Hooks
Related hooks will be displayed here in future updates.