【发布时间】:2015-09-11 07:34:37
【问题描述】:
我只想显示分类“product-brand”中没有术语“brand-slug”的帖子。
我当前的查询没有应用过滤器:
SELECT DISTINCT * FROM $wpdb->posts AS p
LEFT JOIN $wpdb->postmeta AS meta ON p.ID = meta.post_id
LEFT JOIN $wpdb->term_relationships AS rel ON rel.object_id = p.ID
LEFT JOIN $wpdb->term_taxonomy AS tax ON tax.term_taxonomy_id = rel.term_taxonomy_id
LEFT JOIN $wpdb->terms AS term ON tax.term_id = term.term_id
WHERE 1=1
AND p.post_type = 'product'
AND p.post_status = 'publish'
AND p.post_title LIKE '%$trimmed%' OR (meta.meta_key = 'product_model' AND meta.meta_value LIKE '%$trimmed%')
AND (tax.taxonomy = 'product-brand' AND term.slug NOT IN ('$protected'))
分类法或 slug 条件似乎在上述查询中都不起作用。
感谢任何帮助!
【问题讨论】:
标签: php mysql wordpress custom-taxonomy