2011-11-28 2 views
0

get_terms() 함수에 문제가 있습니다.WordPress get_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'); 
print_r($terms); 
?> 

내가 다시 배열을 얻을 .

Array () 

이 하나가 내가 잘못 알고 있나요 :

<?php 
$terms = get_terms('location', array('parent' => 9)); 
print_r($terms); 
?> 

나는이 얻을?

감사 피트

답변

2

좋아, 내가이 문제를 해결했다.

조금 이상했습니다. 내 모든 용어는 wp_insert_term 함수를 사용하여 스크립트를 통해 추가되었습니다. edit-tags.php? taxonomy = 대시 보드의 위치 페이지에 갔을 때 오른쪽 목록의 상위 3 개 용어 만 볼 수 있었지만 나머지는 왼쪽 구름으로 볼 수있었습니다.

나는 용어 ​​중 하나에 들어가서 그것을 저장했다. 그리고 그들은 모두 오른쪽의리스트와 나의 배열에 나타난다.

나는 용어 ​​목록에 어떤 종류의 캐싱이 있었음에 틀림 없다고 생각합니다. 계층 구조를보기 위해 대시 보드를 통해 저장해야했습니다.

나는 이상한 것을 인정해야한다.

피트

0

계층이 캐시 및 wp_insert_term 후 자동으로 무효화되지 않습니다. 당신은

delete_option("{$taxonomy}_children");

수동으로 계층 구조에 대한 다음 액세스에 재생을 강제로 호출 할 수 있습니다.

관련 문제