php - 从 PHP 查询中排除标签
问题描述
我在我的子主题functions.php
文件中编写了以下查询。
目前这完全符合它的需要,但是我希望扩展这个查询,以便它排除特定的标签。
'post_type' => 'product',
'meta_key' => 'total_sales',
'orderby' => 'meta_value_num',
'posts_per_page' => 10,
'tax_query' => array(
array(
'taxonomy' => 'product_tag',
'terms' => 492,
'field' => 'id',
),
),
);
解决方案
您可以使用'compare' => 'NOT IN'
.
'post_type' => 'product',
'meta_key' => 'total_sales',
'orderby' => 'meta_value_num',
'posts_per_page' => 10,
'tax_query' => array(
array(
'taxonomy' => 'product_tag',
'terms' => array( 492, 422 ),
'field' => 'id',
'compare' => 'NOT IN'
),
),
有用的链接
推荐阅读
- c - 是否可以在 c 中创建自定义大小的变量类型?
- python - Python:POST请求状态码200不允许json转换
- kubernetes - 如何处理不完整的提供的秘密
- widget - 如何为 pyinstaller 指定路径
- ngx-translate - 获取默认语言环境翻译值和浏览器语言翻译值
- javascript - 我可以使用 Infinity 和 -Infinity 作为 Max 和 Min 变量的初始值吗?
- flutter - 如何在 google admob 上删除测试广告文字
- amazon-s3 - 如何在不使用 Confluent 的情况下使用 Kakfa Connect 从 Kafka 将数据发送到 AWS S3?
- javascript - javascript使用中的正则表达式失败
- html - 修复图像附近名称标签的问题