widget_comments_args
Filters the arguments for the Recent Comments widget.
Usage
add_filter( 'widget_comments_args', 'wp_kama_widget_comments_args_filter', 10, 2 ); /** * Function for `widget_comments_args` filter-hook. * * @param array $comment_args An array of arguments used to retrieve the recent comments. * @param array $instance Array of settings for the current widget. * * @return array */ function wp_kama_widget_comments_args_filter( $comment_args, $instance ){ // filter... return $comment_args; }
- $comment_args(array)
- An array of arguments used to retrieve the recent comments.
- $instance(array)
- Array of settings for the current widget.
Changelog
Since 3.4.0 | Introduced. |
Since 4.9.0 | Added the $instance parameter. |
Where the hook is called
widget_comments_args
wp-includes/widgets/class-wp-widget-recent-comments.php 109-117
apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish', ), $instance )
wp-includes/blocks/latest-comments.php 48-56
apply_filters( 'widget_comments_args', array( 'number' => $attributes['commentsToShow'], 'status' => 'approve', 'post_status' => 'publish', ), array() )