我有以下代码,我想在该函数中使用term\\u id。我知道变量$terms包含术语;然而,我不知道如何从中获取术语id。
add_action(\'set_object_terms\',\'wpse5123_set_object_terms\',10,4);
function wpse5123_set_object_terms($object_id, $terms, $tt_ids, $taxonomy){
if($taxonomy == \'category\'){
echo \'<pre>\';
print_r($terms);
exit;
}
}
我尝试了以下方法,但不起作用:foreach ( $terms as $term) {
$term_id[] = $term->term_id;
}