Want to show more than 15 recent posts in your WordPress sidebar? The old 15-post limit described in this tutorial applied to earlier versions of WordPress. Current WordPress versions let you set the number of posts in the built-in Recent Posts widget, so check the widget settings first. If you need to enforce a specific number or the setting is being overridden, you can use a small filter in a site-specific plugin or a child theme instead of editing WordPress core files.

This guide covers the current method, a code-based alternative, and the historical core-file edit for reference. Do not edit files inside
wp-includes. WordPress updates can overwrite those changes, and modifying core files makes maintenance and troubleshooting harder.
Set the number of recent posts in WordPress
- Open your WordPress dashboard and go to Appearance → Widgets. Depending on your theme and WordPress version, you may manage widgets in the Site Editor or Customizer instead.
- Open the sidebar or widget area containing Recent Posts.
- Find the Number of posts to show setting and enter the number you want, such as 30.
- Save or update the widget, then visit the front end to confirm the list displays as expected.
If the widget does not offer the setting you need, or another plugin or custom function is changing the query, use the filter below.
Use a WordPress filter to show 30 recent posts
WordPress provides the widget_posts_args filter for changing the query used by the built-in Recent Posts widget. Add the following code to your child theme's functions.php file or, preferably, a small site-specific plugin. Do not add it to a parent theme or a WordPress core file.
/**
* Set the built-in Recent Posts widget to show 30 posts.
*/
function lancelhoff_recent_posts_widget_args( $args, $instance ) {
$args['posts_per_page'] = 30;
return $args;
}
add_filter( 'widget_posts_args', 'lancelhoff_recent_posts_widget_args', 10, 2 );
Important: This filter applies to every built-in Recent Posts widget on the site and forces each one to show 30 posts, regardless of its individual number setting. Change 30 to your preferred count. If you only want to change one widget, use a condition based on that widget's settings or use a dedicated custom widget/query instead.
Where should the code go?
- Site-specific plugin: Best when the behavior should remain active if you change themes.
- Child theme
functions.php: Suitable if the change belongs with your child theme. Back up the file before editing. - Parent theme or WordPress core: Avoid. Theme updates can overwrite parent-theme changes, and WordPress updates replace core files.
Historical method: editing a WordPress core file
In the original WordPress 2.8-era method, the steps were to back up wp-includes/default-widgets.php, open it in a text editor, find the Recent Posts widget code that capped $number at 15, change the cap to 30, and update the related “at most 15” help text to “at most 30.” The edited file was then uploaded to replace the core file on the server.
This is historical information, not a recommendation. Do not apply those steps to a current WordPress installation. The file and implementation have changed, core-file edits are unsupported, and updates can overwrite them. Use the widget setting or the widget_posts_args filter above instead.
Frequently asked questions
Can WordPress display more than 15 recent posts?
Yes. The old 15-post limit is outdated. Check the Recent Posts widget's number setting first. If you need to force a specific count, the widget_posts_args filter can change the query.
Will editing a WordPress core file survive an update?
No. WordPress updates can replace core files and remove your changes. Editing core files can also make future updates and troubleshooting more difficult.
Does the filter change every Recent Posts widget?
Yes. The example above changes the query for every built-in Recent Posts widget. If you need different counts for different widget instances, add conditional logic or use a custom widget/query.
Where can I learn more about the filter?
The official WordPress Developer Resources document the widget_posts_args filter and show how it is used by the Recent Posts widget. See the Recent Posts widget source documentation.
