未公布(草案)的博客文章都出现在网页上是我的WP查询为什么文章草稿显示在我的主页时,选择一个类别,但我不希望显示它在我家page.Here
<div class="wm_container wm_row wm_blog_listing">
<?php
$wm_home_blog_args = array(
'post_type' => 'post',
'posts_per_page' => 4,
);
$wm_home_blog_qry = new WP_Query($wm_home_blog_args);
if ($wm_home_blog_qry->have_posts()) {
while ($wm_home_blog_qry->have_posts()) {
$wm_home_blog_qry->the_post();
$wm_categories = get_the_category($post->ID);
$wm_home_term_ID = $wm_categories[0]->term_id;
$wm_home_blog_bg = get_term_meta($wm_home_term_ID, 'wm_term_color', true);
?>
<article class="wm_col wm_col_3 wm_blog_item"
style="background-color: <?php echo $wm_home_blog_bg; ?>">
<?php
if (has_post_thumbnail()) {
?>
<a class="wm_post_thumbnail_wrapper" href="<?php the_permalink() ?>">
<?php
the_post_thumbnail('wm_recent_issue_cat');
?>
<span class="wm_image_overlay">Preview</span>
</a>
<?php
} else {
?>
<a class="wm_post_thumbnail_wrapper" href="<?php the_permalink() ?>">
<img src="http://placehold.it/255x135?text=No+Image">
<span class="wm_image_overlay">Preview</span>
</a>
<?php
}
?>
在阵列
$wm_home_blog_args = array(
'post_type' => 'post',
'posts_per_page' => 4,
'post_status' => 'publish',
);
它非常有帮助我,但不知道为什么,我的问题仍然是:( – Talha
谢谢分享。 – Talha
你想甩了你'get_post_status'内环路,只是为了确保显示的帖子是'draft'确实(或许你是从不同的DB或拉的东西,你的数据没有预见到) – arhak