WP_Query-显示粘性帖子时,” category__not_in”不起作用

我正在尝试显示前4个没有视频类别的即时贴, 这是我当前的循环:

<?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; ?>

但是我仍然看到带有视频类别的帖子。我不完全确定为什么此循环不遵守category__not_in, 有什么想法吗?


#1


尝试这个:


你可能需要在category_not_in中提供一个数组值。而且由于get_cat_ID()函数返回字符串/整数, 因此你可能需要这样做->’category__not_in’=> array($ videos_cat_id)

来源:

https://www.srcmini02.com/66427.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_37088.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?