widget_posts_args
Filters the arguments for the Recent Posts widget.
Usage
add_filter( 'widget_posts_args', 'wp_kama_widget_posts_args_filter', 10, 2 ); /** * Function for `widget_posts_args` filter-hook. * * @param array $args An array of arguments used to retrieve the recent posts. * @param array $instance Array of settings for the current widget. * * @return array */ function wp_kama_widget_posts_args_filter( $args, $instance ){ // filter... return $args; }
- $args(array)
- An array of arguments used to retrieve the recent posts.
- $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-includes/widgets/class-wp-widget-recent-posts.php 73-82
apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, ), $instance )