Filter hook 'widget_posts_args'

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

View Source

widget_posts_args

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

Hook Information

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

Hook Parameters

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

Usage Examples

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

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

Source Code Context

wp-includes/widgets/class-wp-widget-recent-posts.php:73 - How this hook is used in WordPress core
<?php
  68  			 * @see WP_Query::get_posts()
  69  			 *
  70  			 * @param array $args     An array of arguments used to retrieve the recent posts.
  71  			 * @param array $instance Array of settings for the current widget.
  72  			 */
  73  			apply_filters(
  74  				'widget_posts_args',
  75  				array(
  76  					'posts_per_page'      => $number,
  77  					'no_found_rows'       => true,
  78  					'post_status'         => 'publish',

PHP Documentation

<?php
/**
			 * Filters the arguments for the Recent Posts widget.
			 *
			 * @since 3.4.0
			 * @since 4.9.0 Added the `$instance` parameter.
			 *
			 * @see WP_Query::get_posts()
			 *
			 * @param array $args     An array of arguments used to retrieve the recent posts.
			 * @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-posts.php
Related Hooks

Related hooks will be displayed here in future updates.