반응형
워드프레스에서 상위 카테고리 ID별로 하위 카테고리를 얻는 방법
제발, 누가 나를 도와줄 수 있나요, 나는 워드프레스 세계에 처음입니다.워드프레스에서 상위 카테고리 ID별로 하위 카테고리를 얻는 방법
를 사용해야 합니다.get_terms($taxonomies, $args);
$parent_term_id = 4; // term id of parent term (edited missing semi colon)
$taxonomies = array(
'category',
);
$args = array(
'parent' => $parent_term_id,
// 'child_of' => $parent_term_id,
);
$terms = get_terms($taxonomies, $args);
또,'child_of'
대신,
주의: child_of와 parent의 차이는 부모가 부모 용어의 직계 자녀만 얻는 경우(즉, 1레벨 아래), child_of는 모든 하위 자녀(사용 가능한 수준 수)입니다.
Codex: get_terms
다음은 특정 부모로부터 자식 범주를 가져오는 가장 간단한 방법입니다.
$parent_id = 12;
$termchildren = get_terms('product_cat',array('child_of' => $parent_id));
언급URL : https://stackoverflow.com/questions/22443352/how-to-get-sub-categories-by-parent-category-id-in-wordpress
반응형
'sourcecode' 카테고리의 다른 글
jQuery.parseJSON 작은따옴표와 큰따옴표 (0) | 2023.02.11 |
---|---|
React.render()와 ReactDOM.render() 사이에 차이가 있습니까? (0) | 2023.02.11 |
Fishpig를 사용하여 페이지 표시 작성 (0) | 2023.02.07 |
Wordpress 투명 OAuth 1.0 PHP 로그인 (0) | 2023.02.07 |
'SubSonic' 유형의 개체를 직렬화하는 동안 순환 참조가 탐지되었습니다.스키마Database Column'을 클릭합니다. (0) | 2023.02.07 |