WordPress increase number of Recent Posts.

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:

Changing the default number of recent posts

Changing the default number of recent posts

		$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

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

Related posts:

  1. WordPress pin text or banner to top of posts?
  2. Google AJAX Translation not working with WordPress & Artisteer
  3. “Increase Google Page Rank” It’s official – I now hate Google.
  4. WordPress database error: [The used table type doesn't support FULLTEXT indexes]
  5. Ultimate GA doesn’t work with my WordPress theme – Missing urchin.js|Missing _uacct|Missing urchinTracker
  6. Upgrade WordPress Automatically – The Sauron plugin
  7. WordPress’ 20 BEST Plugins for Ultimate Blogging.


2 Comments

  1. Comments  Taras N. Dyatlik   |  Tuesday, 30 November 2010 at 5:39 pm

    Thank you very much! It worked!

  2. Comments  Puritan Rweformed Bookstore   |  Saturday, 08 January 2011 at 9:14 pm

    Hey man thanks a million,I have apx 5-6 hrs over a period of time searching for a fix,your the only one that really did this!

Leave a Reply