我想通过给定的posts id获取terms对象。我对sql了解不多,这对我来说有点复杂。以下是我尝试的内容:
global $wpdb;
$taxonomy = \'category\'
$term= $wpdb->prefix.\'terms\';
$relations= $wpdb->prefix.\'term_relationships\';
$taxo = $wpdb->prefix.\'term_taxonomy\';
$sql = "SELECT $term.*, $relations.*, $taxo.*
FROM $term
JOIN $relations
ON $term.term_id = \'$taxo.term_id\'
JOIN $taxo
ON $relations.term_taxonomy_id = $taxo.term_taxonomy_id
WHERE $taxo.taxonomy = \'$taxonomy\' AND $relations.object_id IN (116,118)
GROUP BY $term.term_id";
$values = $wpdb->get_results($sql, ARRAY_A);
不知道怎么了。这就是行不通。