php - 分类的自定义查询
问题描述
我正在使用此查询来显示某些帖子。
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
而是想排除它们。我尝试了以这种形式找到的所有解决方案,但没有任何效果。有任何想法吗?
解决方案
您可以使用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',
),
),
) );
推荐阅读
- angular - TypeScript:构造函数参数列表中的赋值运算符?
- oracle - 如何使用codeigniter制作pdf?
- teamcity - 从 TeamCity 构建步骤开始后台进程
- python - 如何将列表转换为字典 python;字典的键可能有多个值吗?
- ios - 更新到 ARC Obj-c 后声音不播放
- python - Python中的对象分配意外行为
- android - 为什么我的套接字客户端收到多个广播消息?
- python - 如何在 TensorFlow 中使用 Hugging Face Transformers 库对自定义数据进行文本分类?
- python - 如何检查从 doc.table 中提取的空 document.paragraph 值?
- c# - 拆分逗号以将多行插入数据库 (ASP.NET MVC)