0
我想在wordpress中製作一個過濾器。由slu word的wordpress過濾器
我想選擇查找所有選定標籤slu posts的帖子。
$ vare_array是「tagshopconverse,tagcategorysko,tagbrandconverse」
這個選擇正與「或」 - 它的發現與標籤, 但並不適用於所有職位「和」 ,我需要他們具有包容性 - 所有標籤必須在帖子中。
$slugs = "";
$andor = " AND ";
foreach($vare_array as $vare) {
$slugs = $slugs . $andor ."$wpdb->terms.slug = '".$vare."'";
$andor = " OR ";
}
$postids = $wpdb->get_col($wpdb->prepare("
SELECT *
FROM $wpdb->posts
LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
LEFT JOIN $wpdb->terms ON($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id)
WHERE $wpdb->posts.post_type = 'post'
AND $wpdb->posts.post_status = 'publish'
{$slugs}
"));
/感謝