How to add a drafts link to your WordPress posts menu with a plugin

Protect your baby bird WordPress functions inside the warm nest of a plugin. Image via flickr/Alex Proimos. Generic (CC BY-NC 2.0).
David Walsh has the secret sauce for getting a link to your post drafts in the posts menu option of your WordPress site. Yes! I built upon his work and created a custom plugin that does the same. Why? Because I hate it when a site update wipes out my functions.php custom code. By using a plugin, you can keep this handy-dandy shortcut secure amid the next upgrade.

To do this, just copy the code below into a text file, save it as yourspecialsecretsauce.php, drop it into your plugins directory, and activate it.

Plugin code:


<?php

/*
Plugin Name: Drafts Link in Posts Menu
Plugin URI: https://davidwalsh.name/wordpress-admin-add-menu-item
Description: Adds a link to draft items from the Posts admin menu. Amedeo at hellotumo.com took David's work and made it into a plugin.
Version: 1.0
*/

function add_drafts_admin_menu_item() {
// $page_title, $menu_title, $capability, $menu_slug, $callback_function
add_posts_page(__('Drafts'), __('Drafts'), 'read', 'edit.php?post_status=draft&post_type=post');
}

add_action('admin_menu', 'add_drafts_admin_menu_item');

?>

Leave a Reply

%d bloggers like this: