From 530ffc712f9be8b54aec3a63d36604e6a36c36bd Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Sat, 9 Jan 2016 04:43:33 +0000 Subject: [PATCH] Introduce `comments_template_query_args` filter. This new filter gives developers a way to target the arguments used for comment queries specifically when populating the main comment template. Props birgire. Fixes #34442. git-svn-id: https://develop.svn.wordpress.org/trunk@36235 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/comment-template.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php index 64b4ba8e53..ff44840e97 100644 --- a/src/wp-includes/comment-template.php +++ b/src/wp-includes/comment-template.php @@ -1337,6 +1337,26 @@ function comments_template( $file = '/comments.php', $separate_comments = false } } + /** + * Filters the arguments used to query comments in comments_template(). + * + * @since 4.5.0 + * + * @param array $comment_args { + * Array of arguments. See WP_Comment_Query::__construct() for detailed descriptions. + * + * @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 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. + * } + */ + $comment_args = apply_filters( 'comments_template_query_args', $comment_args ); $comment_query = new WP_Comment_Query( $comment_args ); $_comments = $comment_query->comments;