donglianjiang9321 2014-11-14 09:02 采纳率: 0%
浏览 7

too long

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?

  • 写回答

1条回答 默认 最新

  • drxdn40242 2014-11-14 11:37
    关注

    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 );

    评论

报告相同问题?

悬赏问题

  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题