get_the_terms不返回cat_id

时间:2014-09-17 17:41:24

标签: wordpress loops taxonomy

我使用此代码来获取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。

1 个答案:

答案 0 :(得分:3)

term_idcat_ID相同。 filter包含过滤帖子内容的上下文。

raw =>未经过数据处理的数据

Read here about filter