I want to prevent post status by user capability. Like 'draft' and 'pending' status display when author is logged in and 'publish' status display when editor is logged in.
0
votes
1 Answers
0
votes
You can try this:
<?php
if ( is_user_logged_in() ) {
$args = array( 'post_type' => 'post', 'post_status' => 'publish, pending, draft' );
} else {
$args = array( 'post_type' => 'post', 'post_status' => 'publish' );
}
$wp_query = new WP_Query($args); while ( have_posts() ) : the_post(); ?>
CONTENT
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>