If you want to know how to increase the number of ‘recent posts’ that appear in your WordPress sidebar here’s how you can do it.
The default maximum allowed is 15 – well I would like to have 30, so this will involve a little bit of hacking of WordPress’ PHP but it’s not difficult.
You need to locate the file ‘default-widgets.php’ which you will find in your wp-includes folder. For me because I’m using WordPress 2.8.4 the code I need is on line 542 and 543. The code was as follows:

$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title']); if ( !$number = (int) $instance['number'] ) $number = 10; else if ( $number < 1 ) $number = 1; else if ( $number > 15 ) $number = 15;
And I just changed the code so that the else if logic would be > 30, like so…
$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title']); if ( !$number = (int) $instance['number'] ) $number = 10; else if ( $number < 1 ) $number = 1; else if ( $number > 30 ) $number = 30;
The last thing you have to do is change the max value for the number of recent posts in your WordPress installation.
WordPress Install > Appearance > Widgets > Recent Posts
And just change the value to your new max value ie. 30. Ignore the text that says: (at most 15)
And you’re good to go…
Simon
2 comments