Override default-widget options
-
It’s always bothered me that when I add an Archives Widget, it lists all available posts by month leading to a very long list for me. In the Widget manipulation tool within WordPress there is no option to modify the parameters for the default archive widget other than to set things like show post count and whether or not to use a drop down.
After some searching I discovered I could limit the number of items in the archive by adding a parameter to the wp_get_archives() call, the only problem being the call is made inside /wp-includes/defaults-widget.php. For example, in WordPress 3.2 I can change line 238 to be:
<?php wp_get_archives(apply_filters('widget_archives_args', array('limit' => 12, 'type' => 'monthly', 'show_post_count' => $c))); ?>Which will then restrict the archive to the last 12 months. I have two questions:
1) Where can I put in a feature request to have the “limit” variable configurable within the WordPress widget management tool. It seems like a missing feature to me.
2) What’s the “best” way to override this since the code change I made will be overwritten as soon as I update WordPress. Do I replace the entire class WP_Widget_Archives, the function WP_Widget_Archives.widget(), or just change one of the initializers? Can I modify my theme or do I need to create a plugin?
The topic ‘Override default-widget options’ is closed to new replies.