我试图计算自定义职位类型“jobs”的总职位数。当我知道有帖子时,我的查询只返回“0”。我不认为这是在检查帖子类型是否有帖子,但我不知道为什么。。。有什么想法吗?
<?php $jobs = new WP_Query(array( \'post_type\' => \'jobs\' ));?>
<?php if ($jobs->have_posts()) {
$count_posts = wp_count_posts()->publish;
if ( $count_posts == "1" ) {
echo "<h2>There is currently one vacancy...</h2>"; }
else { echo "<h2>There are currently $count_posts vacancies...</h2>"; }
} else { ?>
<h2>There are currently no vacancies.</h2>
<?php } ?>