我在一个网站上工作,我做了一个循环,显示所有帖子甚至草稿。我想避免这样,所以我\'post_status\' => \'publish\'
, 但它不起作用。有人能帮我吗?
<?php
global $actu_pageId;
if (get_the_ID() == $actu_pageId) {
$posts = new WP_Query(array(\'post_status\' => \'publish\', \'posts_per_page\' => 9));
} else {
$posts = new WP_Query(array(\'posts_per_page\' => 9, \'post_status\' => \'publish\', \'category_name\' => get_field(\'categorie\')));
}
if ($posts->have_posts()) {
global $posts;
while ($posts->have_posts()) {
$posts->the_post();
get_template_part(\'template-parts/posts_archive\');
}
} else {
// no posts found
}
?>