More drafts on the WordPress dashboard

On WordPress sites I always have the quickdraft widget listed on the top left of the dashboard. This way I can quickly throw ideas into the queue, and go back to what I was doing.

tl;dr The WordPress dashboard has a quick drafts widget. It only lists 3 draft posts, but I like to list quite a few more. This how-to shows you how to customize the back-end code to achieve just that (yay).

There is no separate page for quickdrafts as far as I know. And I am a terrible plugin coder when it comes to WordPress. But if I am allowed to do it, I change it to display the drafts just the way I like it.

This is how it shows by default, up to three drafts, listing the most recently added ones first:

drafts default

There’s a little bug there by the way. It’s hard coded to list 4, but it only will display 3. Which is odd. But whatever, typical WordPress if you ask me.

And this is what it should look like when we’re done, showing more than 3, and listing the oldest drafts first (so we don’t forget about them):

drafts default

Okay, here’s how I do it:

In your sftp client, open the wp-admin/includes/dashboard.php file, and find this function:
wp_dashboard_recent_drafts

Inside this function it will have this line of code:
'posts_per_page' => 4,
change it to the value you wish:
'posts_per_page' => 12,
(12 meaning, show me 12 drafts if there are any)

Ok now find this line a bit further down in the same function:
$drafts = array_slice( $drafts, 0, 3 );
change it to the value you just set the other one to:
$drafts = array_slice( $drafts, 0, 12 );

[Optional] I prefer if the oldest draft shows first, still in the same function you should see this line:
'order' => 'DESC'
change it to this:
'order' => 'ASC'

Save the file, refresh the wp-admin/index.php file in the browser and if you have more than 3 drafts, it should now list up to 12 of them.


Posted

in

by

Tags: