对于分类自定义查询

问题描述 投票:0回答:1

我使用该查询显示某些职位。

query_posts( array(
                    'post_type' => APP_POST_TYPE,
                    'post_status' => 'publish',
                    'posts_per_page' => 4,
                    APP_TAX_STORE => $term->slug,
                    ),                      
                ) );

现在,而不是显示APP_TAX_STORE => $term->slug的所有帖子,我想将它们排除在外。我想在这种形式中找到的所有解决方案,但毫无效果。有任何想法吗?

php wordpress posts
1个回答
1
投票

您可以使用tax_query

query_posts( array(
  'post_type'      => APP_POST_TYPE,
  'post_status'    => 'publish',
  'posts_per_page' => 4,
  'tax_query'      => array(
    array(
      'taxonomy' => APP_TAX_STORE,
      'field'    => 'slug',
      'terms'    => $term->slug,
      'operator' => 'NOT IN',
    ),
  ),
) );
© www.soinside.com 2019 - 2024. All rights reserved.