简体   繁体   中英

What's the difference between term_id, term_taxonomy_id and cat_ID?

I'm working on a plugin and there I need cat_ID . I used this function, get_the_terms( $id,'category' ); and I am getting an array like this:

  Array
  (
     [10] => stdClass Object
         (
            [term_id] => 10
            [name] => Personal
            [slug] => personal
            [term_group] => 0
            [term_taxonomy_id] => 10
            [taxonomy] => category
            [description] => 
            [parent] => 0
            [count] => 3
            [object_id] => 1
            [filter] => raw
        )

 )

There should be a cat_ID but I can't find any.

It seems like term_taxonomy_id and term_id are showing what I'd expect to see in cat_ID , but somehow I came to know that sometimes term_id is different than term_taxonomy_id .

For example, if I delete a category and then create another, then the term_id will not be equal to cat_ID , will it?

Is it safe to use term_taxonomy_id as cat_ID ? What's the difference between them all?

term_id and cat_ID always have the same value. You aren't seeing category specific properties because you've used get_the_terms() instead of get_the_category() .

Change to get_the_category( $id );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM