WordPress filter hook · part of WordPress core
widget_comments_args
A WordPress core filter that 22 plugins also fire themselves, running on 407K+ sites between them.
“This filter is documented in wp-includes/widgets/class-wp-widget-recent-comments.php”
How to use widget_comments_args
It's a filter: your callback receives the value, and must return the (changed) value.
Add this to your theme's functions.php or a small custom plugin:
add_filter( 'widget_comments_args', function( $query_args ) {
// Change $query_args here.
return $query_args;
}, 10, 1 );Argument names come from Video Gallery's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
This hook is fired by WordPress core too. Official reference on developer.wordpress.org →
22 plugins that fire widget_comments_args
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
Gutenberg400,000+ installs
apply_filters( 'widget_comments_args', array( 'number' => $attributes['commentsToShow'], 'status' => 'approve', 'post_status' => 'publish', ), array() )build/scripts/block-library/latest-comments.php:55 -
WpStream3,000+ installs
apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish', ), $instance )hello-wpstream/framework/widgets/class-wpstream-recent-comments-widget.php:65 -
Video Gallery2,000+ installs
apply_filters( 'widget_comments_args', $this->query_args )includes/class-emd-widget.php:355 -
xili-language600+ installs
apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) )xili-includes/xili-language-widgets.php:317 -
Customer Support Ticket System & Helpdesk400+ installs
apply_filters( 'widget_comments_args', $this->query_args )includes/class-emd-widget.php:355 -
Employee Spotlight300+ installs
apply_filters( 'widget_comments_args', $this->query_args )includes/class-emd-widget.php:355 -
Employee Directory100+ installs
apply_filters( 'widget_comments_args', $this->query_args )includes/class-emd-widget.php:355 -
Recent Comments Widget with Comment Excerpts100+ installs
apply_filters( 'widget_comments_args', array( 'number' => 150, 'status' => 'approve', 'post_status' => 'publish', ), $instance )recent_comments_widget_with_excerpts.php:72 -
Polygon Recent Comments With Avatar100+ installs
apply_filters( 'widget_comments_args', array('number' => $num_comments, 'status' => 'approve', 'post_status' => 'publish', 'type' => 'comment') )polygon-recent-comments-with-avatar.php:90 -
WP Recent Comments With Avatars80+ installs
apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish', 'type' => 'comment' ) )wp-recent-comments-with-avatars.php:79 -
FF Tab Widget70+ installs
apply_filters( 'widget_comments_args', array( 'number' => $commentlimit, 'status' => 'approve', 'post_status' => 'publish' ) )ff-tab-widget.php:312 -
Simple Contact Form Plugin for WordPress40+ installs
apply_filters( 'widget_comments_args', $this->query_args )includes/class-emd-widget.php:355 -
Project Management, Bug and Issue Tracking Plugin20+ installs
apply_filters( 'widget_comments_args', $this->query_args )includes/class-emd-widget.php:355 -
Event RSVP and Simple Event Management Plugin20+ installs
apply_filters( 'widget_comments_args', $this->query_args )includes/class-emd-widget.php:355 -
JS Widgets10+ installs
apply_filters( 'widget_comments_args', array( 'number' => $instance['number'], 'status' => 'approve', 'post_status' => 'publish', ) )core-adapter-widgets/recent-comments/class.php:76 -
Easy Accordion FAQ and Knowledge Base Software for WordPress10+ installs
apply_filters( 'widget_comments_args', $this->query_args )includes/class-emd-widget.php:355 -
HTML Classified Recent Posts & Comments Widgets10+ installs
apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) )html-classified-recent-post-comments-widgets.php:175 -
Pz-RecentComments10+ installs
apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'type' => 'comment', 'post_status' => 'publish' ) )pz-recentcomments.php:42 -
Smart Recent Comments10+ installs
apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) )index.php:88 -
Advance Widget Pack10+ installs
apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish', ) )includes/class-awp-recent-comments.php:27 -
Poly CommentsFewer than 10 installs
apply_filters( 'widget_comments_args', array('number' => $num_comments, 'status' => 'approve', 'post_status' => 'publish', 'type' => 'comment') )includes/widgets.php:53 -
Fox009 Recent Comments WidgetFewer than 10 installs
apply_filters( 'widget_comments_args', array( 'post_type' => '', 'number' => $comment_params['number'], 'offset' => $comment_params['offset'], 'orderby' => $comment_params['orderby'], 'order' => $comment_params['order'], 'status' => $comment_params['status'], 'type' => $comment_params['type'] ) )includes/widget.php:14
Need a customisation built on this hook?
Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.