apply_filters( 'widget_posts_args', array $args , array $instance )
Filters the arguments for the Recent Posts widget.
Description Description
See also See also
Parameters Parameters
- $args
-
(array) An array of arguments used to retrieve the recent posts.
- $instance
-
(array) Array of settings for the current widget.
Source Source
Changelog Changelog
| Version | Description |
|---|---|
| 4.9.0 | Added the $instance parameter. |
| 3.4.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Adding to my custom theme in functions.php:
//filter recent posts widgets by category name function myorg_recentposts_events($args, $instance) { $args['category_name'] = 'upcoming-events'; return $args; } add_filter('widget_posts_args', 'myorg_recentposts_events', 1, 2);Most important,
return $args!! Spent an hour trying to figure out why my filter wasn’t working.