我遇到了get_terms()函數的問題。返回空數組的WordPress get_terms
如果我使用:
<?php
$terms = get_terms('location');
print_r($terms);
?>
我得到一個數組回來:
Array ([0] => stdClass Object ([term_id] => 8 [name] => Aberdare [slug] => aberdare [term_group] => 0 [term_taxonomy_id] => 8 [taxonomy] => location [description] => [parent] => 7 [count] => 1) [1] => stdClass Object ([term_id] => 10 [name] => Aberdeen [slug] => aberdeen [term_group] => 0 [term_taxonomy_id] => 10 [taxonomy] => location [description] => [parent] => 9 [count] => 14) [2] => stdClass Object ([term_id] => 17 [name] => Aberdeenshire [slug] => aberdeenshire [term_group] => 0 [term_taxonomy_id] => 17 [taxonomy] => location [description] => [parent] => 9 [count] => 41) [3] => stdClass Object ([term_id] => 1203 [name] => Aberdour [slug] => aberdour [term_group] => 0 [term_taxonomy_id] => 1203 [taxonomy] => location [description] => [parent] => 446 [count] => 1);
但是,如果我試圖用任何數量的陣列child_of的母公司獲得的條款回來空。
<?php
$terms = get_terms('location', array('parent' => 9));
print_r($terms);
?>
我得到這個:
Array ()
是否有任何人知道我做錯了嗎?
感謝 皮特