widget_comments_args filter-hookWP 3.4.0

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

WP_Widget_Recent_Comments::widget()
widget_comments_args
render_block_core_latest_comments()
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 46-54
apply_filters(
	'widget_comments_args',
	array(
		'number'      => $attributes['commentsToShow'],
		'status'      => 'approve',
		'post_status' => 'publish',
	),
	array()
)

Where the hook is used in WordPress

Usage not found.