使用post状态检查postprivate
, 您可以运行以下操作:
if (get_post_status() == \'private\' && is_user_logged_in()) {
// it\'s private and user is logged in, do stuff
} elseif (get_post_status() == \'draft\') {
// it\'s draft, do stuff
} else {
// it\'s something else, do stuff
}
或者,在当前设置中,您只需通过以下方式显示已发布的帖子:
if (get_post_status() == \'publish\') {
// it\'s published, do stuff
$this->render();
}
您可以通过
codex page.