Make WordPress Core

Opened 8 years ago

Last modified 5 years ago

#35456 new enhancement

New args for apply_filters in WP_Widget_Archives

Reported by: sebastianpisula's profile sebastian.pisula Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Widgets Keywords: has-patch needs-docs
Focuses: Cc:


I suggest add new arguments for Widget. For example I can use archive widget for another post types:


 * Filter the arguments for the Archives widget.
 * @since 2.8.0
 * @since 4.5.0 Added new params $widget_args, $instance and $widget_archive
 * @see wp_get_archives()
 * @param array $args An array of Archives option arguments.
 * @param array $widget_args Array of arguments including 'before_title', 'after_title',
 *                           'before_widget', and 'after_widget'.
 * @param array $instance Settings for the current Archives widget instance.
 * @param WP_Widget_Archives $widget_archive Object Current Widget

add_filter( 'widget_archives_args', function ( $args, $widget_args, $instance, $widget ) {

        if ( $widget_args['widget_id'] == 'archives-2' ) {
                $args['post_type'] = 'page';

        return $args;
}, 10, 4 );

I know that date archives is not supported for other post type but this is example (but I can make support for other post type :) )

Attachments (1)

35456.patch (2.1 KB) - added by sebastian.pisula 8 years ago.

Download all attachments as: .zip

Change History (3)

#1 @swissspidy
8 years ago

  • Component changed from General to Widgets
  • Keywords has-patch added

#2 @DrewAPicture
8 years ago

  • Keywords needs-docs added

@sebastian.pisula: Any new arguments will need accompanying changelog entries.

Note: See TracTickets for help on using tickets.