Increase the Number of Recent Posts in WordPress

Increase the number of Recent Posts or Previous posts in WordPress

Recent post is a section which displays  on the footer or on the side bar of your wordpress. This highlights the subject or heading of your posts. This is a useful widget which helps the reader to navigate to other posts in your website.

With the new wordpress 2.8.3 the number of previous posts allowed in 15. Which means it will show upto 15 of the most recent posts. But if you had noticed, revious posts on my blog shows more than 15. Actually I have set it to show upto 50 , just to accomodate future blogs too.

In the latest wordpress this feature can be altered at the wp-includes/default-widgets.php. You will need to change a code value in this page and then make changes at the admin too. Its an easy tweak and virtually nothing can go wrong if followed the instructions carefully..

***BACKUP FILES BEFORE YOU PROCEED..I AM NOT RESPONSIBLE FOR ANY CHANGES YOU DO ON YOUR FILES***

Go to the wp-includes then find the file default-widgets.php . Open this up in a HTML editor or just a word pad.

Find the following code:

$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;

Becareful that if your blogs grow over the time, this can deteriorate the speed of your website since query in the code needs to pull up all these postings. So as a thumb of rule, refrain from putting any number higer than 100

Change the value of 15 to any number you choose, I have opted for 50 , so the altered code will look like this to me

$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 > 50 )
			$number = 50;

Now upload the changes to server, to overwrite the previous files.

Login to the admin of your wordpress, go to Appreances/Widgets/

If you have set your widget to show on side bar or footer, open that up and change the number to 50 or less.

You will see that the recent posts shows that many posts in the widget.

Hope you find it useful…

4 Comments

  1. Hi. I definitely loved reading through your current article!. High-quality material. I would definitely recommend you to produce articles a bit more often. By doing so, having this type of a helpful webpage I feel you may rank higher at the search engines . I also subscribed for your Feed. Continue the great work!

  2. Have to log in as admin then go to Settings –> Reading –> Syndication feeds show the most recent and then increase the number from 10 to 50.

Leave a Reply

Your email address will not be published. Required fields are marked *