The default Archive widget display monthly archives in a dropdown.
I would like to limit the number of months to 12 (in dropdown).
What filter I should apply in my functions.php?
I tried this, but it gives me parsed error:
add_filter('WP_Widget_Archives','set_number_months');
function set_number_months($args) {
$args = array('number' => 12);
return $args;
}
I also tried with wp_get_archives but same parsed error
Use the
widget_archives_args
filter to add the archives limit.And to limit the number of months in Archives widget dropdown use the following drop down filter.