Filter hook 'comments_template_query_args'

in WP Core File wp-includes/comment-template.php at line 1559

View Source

comments_template_query_args

Filter Hook
Description
Filters the arguments used to query comments in comments_template(). will be included in results. }

Hook Information

File Location wp-includes/comment-template.php View on GitHub
Hook Type Filter
Line Number 1559

Hook Parameters

Type Name Description
array $comment_args { Array of WP_Comment_Query arguments.

Usage Examples

Basic Usage
<?php
// Hook into comments_template_query_args
add_filter('comments_template_query_args', 'my_custom_filter', 10, 1);

function my_custom_filter($comment_args) {
    // Your custom filtering logic here
    return $comment_args;
}

Source Code Context

wp-includes/comment-template.php:1559 - How this hook is used in WordPress core
<?php
1554  	 *     @type bool|string  $hierarchical              Whether to query for comments hierarchically.
1555  	 *     @type int          $offset                    Comment offset.
1556  	 *     @type int          $number                    Number of comments to fetch.
1557  	 * }
1558  	 */
1559  	$comment_args = apply_filters( 'comments_template_query_args', $comment_args );
1560  
1561  	$comment_query = new WP_Comment_Query( $comment_args );
1562  	$_comments     = $comment_query->comments;
1563  
1564  	// Trees must be flattened before they're passed to the walker.

PHP Documentation

<?php
/**
	 * Filters the arguments used to query comments in comments_template().
	 *
	 * @since 4.5.0
	 *
	 * @see WP_Comment_Query::__construct()
	 *
	 * @param array $comment_args {
	 *     Array of WP_Comment_Query arguments.
	 *
	 *     @type string|array $orderby                   Field(s) to order by.
	 *     @type string       $order                     Order of results. Accepts 'ASC' or 'DESC'.
	 *     @type string       $status                    Comment status.
	 *     @type array        $include_unapproved        Array of IDs or email addresses whose unapproved comments
	 *                                                   will be included in results.
	 *     @type int          $post_id                   ID of the post.
	 *     @type bool         $no_found_rows             Whether to refrain from querying for found rows.
	 *     @type bool         $update_comment_meta_cache Whether to prime cache for comment meta.
	 *     @type bool|string  $hierarchical              Whether to query for comments hierarchically.
	 *     @type int          $offset                    Comment offset.
	 *     @type int          $number                    Number of comments to fetch.
	 * }
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/comment-template.php
Related Hooks

Related hooks will be displayed here in future updates.