• currently when I open my post editor I see all posts. I’d like to change the default so that it automatically shows drafts.

Viewing 4 replies - 1 through 4 (of 4 total)
  • How about something like this: This plugin adds “Drafts” to the main and the hover/fly-out menu for Posts.
    Post Status Menu Items
    Rather than hover and click on Posts, it lets you hover and click on “Drafts” instead, if you like.

    You could try something like this:

    function my_admin_menu() {
    	$query_string = array();
    	if (stripos($_SERVER['REQUEST_URI'], 'wp-admin/edit.php') === false) {
    		return;
    	}
    	parse_str($_SERVER['QUERY_STRING'], $query_string);
    	if (!empty($query_string)) {
    		return;
    	}
    	wp_redirect(admin_url('edit.php?post_type=post&post_status=draft'));
    	exit;
    }
    
    add_action(
    	'admin_menu',
    	'my_admin_menu'
    );
    Thread Starter lesdossey

    (@lesdossey)

    Hey Ryan which PHP file would I apply that string of code? I’d like to try it and see if it gives me what I’m looking for.

    ClaytonJames I installed the plugin and it works very nicely.

    Thanks guys

    There are two places you could put this code: in the theme or in a plugin.

    If you want to put it in the theme, you can edit the functions.php file in your active theme’s folder and paste the code in there.

    In your case, I would put it in a plugin, because if you change themes, you’d most likely want to retain that functionality.

    When it comes to plugins, you have two options there as well: regular plugin or must-use plugin. The biggest difference here is that a regular plugin must be activated, but a must-use plugin will be active from the moment it was added.

    Here is how you can create a must-use plugin:

    1. In your wp-content folder, create a new folder called mu-plugins.
    2. Create a new file called, for example, posts-landing-page-redirect.php
    3. Copy and paste the code above

    Now, if you go to your Plugins page in WordPress, you’ll see a new filter called Must-Use, which is where you can see that this plugin is active.

    Give it a try and let us know if it works!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘wp-admin defaults’ is closed to new replies.