Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Allow admins to see draft posts on the front end
Plugin Name: Admin Can View Any Post Type
Description: Allow admins to see can post type
Author: Christopher Davis
Author URI:
add_action( 'pre_get_posts', 'wpse33020_pre_get_posts' );
function wpse33020_pre_get_posts( $query_obj )
// get out of here if this is the admin area
if( is_admin() ) return;
// if this isn't an admin, bail
if( ! current_user_can( 'manage_options' ) ) return;
// if this isn't your slide post type, bail
if( ! isset( $query_obj->query_vars['post_type'] ) || 'slider' != $query_obj->query_vars['post_type'] ) return;
// change our query object to include any post status
$query_obj->query_vars['post_status'] = 'any';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.