Filter hook 'widget_comments_args'

in WP Core File wp-includes/widgets/class-wp-widget-recent-comments.php at line 109

View Source

widget_comments_args

Filter Hook
Description
Filters the arguments for the Recent Comments widget.

Hook Information

File Location wp-includes/widgets/class-wp-widget-recent-comments.php View on GitHub
Hook Type Filter
Line Number 109

Hook Parameters

Type Name Description
array $comment_args An array of arguments used to retrieve the recent comments.
array $instance Array of settings for the current widget.

Usage Examples

Basic Usage
<?php
// Hook into widget_comments_args
add_filter('widget_comments_args', 'my_custom_filter', 10, 2);

function my_custom_filter($comment_args, $instance) {
    // Your custom filtering logic here
    return $comment_args;
}

Source Code Context

wp-includes/widgets/class-wp-widget-recent-comments.php:109 - How this hook is used in WordPress core
<?php
 104  			 * @see WP_Comment_Query::query() for information on accepted arguments.
 105  			 *
 106  			 * @param array $comment_args An array of arguments used to retrieve the recent comments.
 107  			 * @param array $instance     Array of settings for the current widget.
 108  			 */
 109  			apply_filters(
 110  				'widget_comments_args',
 111  				array(
 112  					'number'      => $number,
 113  					'status'      => 'approve',
 114  					'post_status' => 'publish',

PHP Documentation

<?php
/**
			 * Filters the arguments for the Recent Comments widget.
			 *
			 * @since 3.4.0
			 * @since 4.9.0 Added the `$instance` parameter.
			 *
			 * @see WP_Comment_Query::query() for information on accepted arguments.
			 *
			 * @param array $comment_args An array of arguments used to retrieve the recent comments.
			 * @param array $instance     Array of settings for the current widget.
			 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/widgets/class-wp-widget-recent-comments.php
Related Hooks

Related hooks will be displayed here in future updates.