theme development - Exclude categories from wp query not working

Im using this code to exclude a category but it still show all posts in exhibition.$posts = get_posts(array('post_t

Im using this code to exclude a category but it still show all posts in exhibition.

$posts = get_posts(array(
    'post_type' => 'exhibition',
    'taxonomy' => 'categories_for_exhibitions',
    'field' => 'slug',
    'terms' => array('current'),
    'operator' => 'NOT IN',
));

Im using this code to exclude a category but it still show all posts in exhibition.

$posts = get_posts(array(
    'post_type' => 'exhibition',
    'taxonomy' => 'categories_for_exhibitions',
    'field' => 'slug',
    'terms' => array('current'),
    'operator' => 'NOT IN',
));
Share Improve this question edited Apr 23, 2020 at 21:29 Muhammad Adnan Bashir asked Apr 23, 2020 at 19:05 Muhammad Adnan BashirMuhammad Adnan Bashir 93 bronze badges 1
  • Welcome to WordPress Development. I hope you find the answer(s) you are looking for. Our site is different from most - if you have not done so yet, consider checking out the tour and help center to find out how things work. – Matthew Brown aka Lord Matt Commented Apr 23, 2020 at 19:52
Add a comment  | 

1 Answer 1

Reset to default 0

Found the answer so it can benefit someone else

$posts = get_posts(array(
    'post_type' => 'exhibition',
    'tax_query' => array(
            array(
                'taxonomy' => 'categories_for_exhibitions',
                'field'    => 'slug',
                'terms'    => 'current',
                operator => 'NOT IN',
            ),
        )

));

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744537753a4579532.html

相关推荐

  • theme development - Exclude categories from wp query not working

    Im using this code to exclude a category but it still show all posts in exhibition.$posts = get_posts(array('post_t

    1天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信