如何在搜索中选择多个项目?在这里,我有一个作者列表,我想从中获取类别...但它不能用逗号。我需要做什么?
<?php
$author = "4,1,909,900,970,968,5,972,969,965,971";
$categories = $wpdb->get_results("
SELECT DISTINCT(terms.term_id) as ID, terms.name, terms.slug, tax.description
FROM $wpdb->posts as posts
LEFT JOIN $wpdb->term_relationships as relationships ON posts.ID = relationships.object_ID
LEFT JOIN $wpdb->term_taxonomy as tax ON relationships.term_taxonomy_id = tax.term_taxonomy_id
LEFT JOIN $wpdb->terms as terms ON tax.term_id = terms.term_id
WHERE posts.post_status = 'publish' AND
posts.post_author = '$author' AND
tax.taxonomy = 'category'
ORDER BY terms.name ASC
");
?>
答案 0 :(得分:4)