apply_filters( 'widget_posts_args', array $args , array $instance )
Filters the arguments for the Recent Posts widget.
Contents
Description
See also
Parameters
-
$args
array -
An array of arguments used to retrieve the recent posts.
-
$instance
array -
Array of settings for the current widget.
More Information
Use any of the WP_Query parameters for $args.
Source
File: wp-includes/widgets/class-wp-widget-recent-posts.php
.
View all references
apply_filters(
'widget_posts_args',
array(
'posts_per_page' => $number,
'no_found_rows' => true,
'post_status' => 'publish',
'ignore_sticky_posts' => true,
),
$instance
)
Changelog
Version | Description |
---|---|
4.9.0 | Added the $instance parameter. |
3.4.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
Adding to my custom theme in functions.php:
Most important,
return $args
!! Spent an hour trying to figure out why my filter wasn’t working.Example migrated from Codex:
Use the following to sort recent posts of the widget by date. Add the code to the
functions.php
file of the child theme.