Opened 9 years ago
Last modified 6 years ago
#35456 new enhancement
New args for apply_filters in WP_Widget_Archives
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Widgets | Keywords: | has-patch needs-docs |
Focuses: | Cc: |
Description
I suggest add new arguments for Widget. For example I can use archive widget for another post types:
<?php /** * 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)
Change History (3)
Note: See
TracTickets for help on using
tickets.
@sebastian.pisula: Any new arguments will need accompanying changelog entries.