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.
Built from https://develop.svn.wordpress.org/trunk@36235


git-svn-id: http://core.svn.wordpress.org/trunk@36202 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2016-01-09 04:44:26 +00:00
parent 4ce9b93af9
commit 72265e4a98
2 changed files with 21 additions and 1 deletions

View File

@ -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;

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.5-alpha-36234';
$wp_version = '4.5-alpha-36235';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.