这将获得数组中所有此类术语的名称
$wpdb->get_col("SELECT DISTINCT {$wpdb->terms}.name FROM {$wpdb->terms}
INNER JOIN {$wpdb->term_taxonomy} ON {$wpdb->term_taxonomy}.term_id = {$wpdb->terms}.term_id
INNER JOIN {$wpdb->term_relationships} ON {$wpdb->term_taxonomy}.term_taxonomy_id = {$wpdb->term_relationships}.term_taxonomy_id
WHERE {$wpdb->term_taxonomy}.taxonomy = \'shape\' AND {$wpdb->term_relationships}.object_id IN (
SELECT object_id FROM {$wpdb->term_relationships}
INNER JOIN {$wpdb->term_taxonomy} ON {$wpdb->term_taxonomy}.term_taxonomy_id = {$wpdb->term_relationships}.term_taxonomy_id
WHERE {$wpdb->term_taxonomy}.taxonomy = \'color\'
);");
如果需要名称以外的更多详细信息,则必须更改字段以选择(&;同时将功能更改为
get_col
到
get_results
请确保分类名称“shape”中没有拼写错误(&P);查询中使用的“颜色”
References-
http://codex.wordpress.org/Class_Reference/wpdb
http://codex.wordpress.org/Database_Description