[wp-trac] [WordPress Trac] #35456: New args for apply_filters in WP_Widget_Archives

WordPress Trac noreply at wordpress.org
Thu Jan 14 14:24:25 UTC 2016


#35456: New args for apply_filters in WP_Widget_Archives
------------------------------+-----------------------------
 Reporter:  sebastian.pisula  |      Owner:
     Type:  enhancement       |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  General           |    Version:
 Severity:  normal            |   Keywords:
  Focuses:                    |
------------------------------+-----------------------------
 I suggest add new arguments for Widget. For example I can use archive
 widget for another post types:

 {{{#!php
 <?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 :) )

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35456>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list