2012-12-07 62 views
0

我想從下面的數組中獲取term_taxonomy_id,但每次它給我以下錯誤。wordpress stdClass對象元素訪問

Catchable fatal error: Object of class WP_Error could not be converted to string in 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

如果你能證明你是如何試圖訪問這個屬性的話,那將是非常棒的。 –

回答

2

你嘗試過什麼來得到這個錯誤?試試這個:

foreach($yourarray as $term){ 
    echo $term->term_taxonomy_id; 
} 
+0

感謝您的幫助。這很簡單,但不知道爲什麼我感到困惑。 –