Created
November 6, 2011 17:42
-
-
Save chrisguitarguy/1343219 to your computer and use it in GitHub Desktop.
Allow admins to see draft posts on the front end
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Admin Can View Any Post Type | |
Description: Allow admins to see can post type | |
Author: Christopher Davis | |
Author URI: http://www.christopherguitar.net/ | |
*/ | |
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