wordpress stdClass对象元素访问

时间:2012-12-07 07:54:58

标签: php arrays wordpress

我想从下面的数组中获取term_taxonomy_id,但每次它都会给我以下错误。

  

捕获致命错误:无法转换类WP_Error的对象   在C中字符串......

 Array
 (
   [0] => stdClass Object
    (
        [term_id] => 5
        [name] => fonts
        [slug] => fonts
        [term_group] => 0
        [term_taxonomy_id] => 5
        [taxonomy] => category
        [description] => 
        [parent] => 0
        [count] => 2
        [object_id] => 96
        [cat_ID] => 5
        [category_count] => 2
        [category_description] => 
        [cat_name] => fonts
        [category_nicename] => fonts
        [category_parent] => 0
    )
)

1 个答案:

答案 0 :(得分:2)

你试图得到什么错误?试试这个:

foreach($yourarray as $term){
  echo $term->term_taxonomy_id;
}
相关问题