gpt4 book ai didi

wordpress - 排除 query_post 自定义分类法中的类别

转载 作者:行者123 更新时间:2023-12-03 07:09:03 24 4
gpt4 key购买 nike

我需要从显示的帖子中排除一个类别。我注册了分类法:投资组合类别并在组合类别下添加了一个类别:配件(目录 ID 19)

如何排除配件类别中的帖子不显示?我尝试过:'category' => -19,但它不起作用这是我的代码:

        <?php
$args=array(
'post_type' => 'items',
'post_status' => 'publish',
'showposts' => intval( get_anolox_option_by('an_homep_count', 3) ),
'caller_get_posts' => 1,
'category' => -19,
'paged' => $paged,
);
query_posts($args);

$end = array(3,6,9,12,15,18,21,24,27,30,33,36,39,42,45);

$i = 0;
while (have_posts()): the_post();
global $post;
$i++;
?>

MY CODE HERE, NO NEED TO SHOW SINCE IT'S VERY LONG



<?php endwhile; ?>
<?php wp_reset_query(); ?>

编辑//我尝试了这段代码,但仍然不起作用:

    <?php
$args=array(
'post_type' => 'items',
'post_status' => 'publish',
'showposts' => intval( get_anolox_option_by('an_homep_count', 3) ),
'caller_get_posts' => 1,

'paged' => $paged,
'tax_query' => array(
'taxonomy' => 'portfolio-category',
'terms' => 'accessories',
'field' => 'slug',
'operator' => 'NOT IN')
);
query_posts($args);

最佳答案

$args = array(
'post_type'=>'items',
'order'=>'ASC',
'posts_per_page'=>3
'tax_query' => array(
array(
'taxonomy' => 'portfolio-category',
'field' => 'id',
'terms' => 19,
'operator' => 'NOT IN',
),
)
));
query_posts($args);

items=自定义帖子类型

投资组合类别 = 我的自定义分类

for multiple category exclude use  'terms' => array( '19,20' ),

关于wordpress - 排除 query_post 自定义分类法中的类别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7577465/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com