按用户能力显示帖子状态下拉列表 [英] Display post status drop down by user capability
本文介绍了按用户能力显示帖子状态下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想根据用户能力阻止发布状态.如作者登录时显示draft"和pending"状态,编辑器登录时显示publish"状态.
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.
推荐答案
你可以试试这个:
<?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(); ?>
这篇关于按用户能力显示帖子状态下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文