我使用此代码来获取cat_id
$terms = get_the_terms( $id,'category' );
foreach( $terms as $term ){
$cats[] = $term->cat_ID;
}
然而当我这样做的时候 的print_r($术语);
这就是我得到的
Array
(
[10] => stdClass Object
(
[term_id] => 10
[name] => Technology
[slug] => technology
[term_group] => 0
[term_taxonomy_id] => 10
[taxonomy] => category
[description] =>
[parent] => 0
[count] => 3
[object_id] => 1
[filter] => raw
)
)
正如您所看到的,cat_ID未包含在内,并且[filter] =>生的。什么是[filter] =>生的 ? 注意:我使用的是wordpress 4.0 谢谢, MMK。
答案 0 :(得分:3)