【发布时间】:2018-08-01 15:16:51
【问题描述】:
我正在尝试显示前 4 个不属于 videos 类别的置顶帖子,这是我当前的循环:
<?php $videos_cat_id = get_cat_ID('videos');
$args = array(
'post__in' => get_option('sticky_posts'),
'category__not_in' => $videos_cat_id,
'ignore_sticky_posts' => 1,
'posts_per_page' => 4,
);
$featured_loop = new WP_Query($args);
if ($featured_loop->have_posts()) :
while ($featured_loop->have_posts()) : $featured_loop->the_post(); ?>
<div class="col-sm-6 m-bottom p-left-none p-right-none">
<?php get_template_part('card-featured') ?>
</div>
<?php endwhile; wp_reset_postdata();
endif; ?>
但我仍然看到呈现videos 类别的帖子。我不完全确定为什么这个循环不尊重category__not_in,有什么想法吗?
【问题讨论】:
标签: php wordpress wordpress-theming custom-wordpress-pages