Search code examples
wordpressloopstaxonomy

get_the_terms does not return cat_id


i am usign this code to get the cat_id

$terms = get_the_terms( $id,'category' );
foreach( $terms as $term ){
    $cats[] = $term->cat_ID;
}

However when i do print_r($terms);

This is what i get

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
        )

)

As you can see the cat_ID is not included and there is [filter] => raw. What is the [filter] => raw ? Note: I am using wordpress 4.0 Thank you, MMK.


Solution

  • term_id is same as cat_ID. filter contains the context under which the contents of the post have been filtered.

    raw => unsanitized data

    Read here about filter