mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 12:50:28 +00:00
Comments: Add a filter for top level comments query arguments in comments_template().
Props hellofromTonya, Howdy_McGee, garrett-eclipse, davidbaumwald, thomaslhotta. Fixes #38074. git-svn-id: https://develop.svn.wordpress.org/trunk@49256 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1434,6 +1434,24 @@ function comments_template( $file = '/comments.php', $separate_comments = false
|
||||
$top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* }
|
||||
*/
|
||||
$top_level_args = apply_filters( 'comments_template_top_level_query_args', $top_level_args );
|
||||
|
||||
$top_level_count = $top_level_query->query( $top_level_args );
|
||||
|
||||
$comment_args['offset'] = ( ceil( $top_level_count / $per_page ) - 1 ) * $per_page;
|
||||
@@ -1463,7 +1481,8 @@ function comments_template( $file = '/comments.php', $separate_comments = false
|
||||
* @type int $number Number of comments to fetch.
|
||||
* }
|
||||
*/
|
||||
$comment_args = apply_filters( 'comments_template_query_args', $comment_args );
|
||||
$comment_args = apply_filters( 'comments_template_query_args', $comment_args );
|
||||
|
||||
$comment_query = new WP_Comment_Query( $comment_args );
|
||||
$_comments = $comment_query->comments;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user