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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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(); ?>