안녕하세요.오늘은 또 카테고리 질문을 하려고 합니다.
특정 카테고리 밑에 4개의 서브카테고리를 만들었습니다.
그런데 서브카테고리중 한개의 카테고리가 관리자에서는 분명 부모카테고리 밑에 있는 계층이 보이는데 글목록을 보려고 사이트보기를 하면 로그를 찍었을 때 부모 카테고리의 정보를 보여주네요…
WP_Term Object (
[term_id] => 79
[name] => TMI 프로젝트 이야기
[slug] => nam_story
[term_group] => 0
[term_taxonomy_id] => 79
[taxonomy] => category
[description] => <p>tmi 프로젝트 이야기</p>
[parent] => 0
[count] => 11
[filter] => raw
[cat_ID] => 79
[category_count] => 11
[category_description] => <p>프로젝트 이야기</p>
[cat_name] => 프로젝트 이야기
[category_nicename] => nam_story
[category_parent] => 0 )
>>코딩<<
if($myposts){
foreach ( $myposts as $post ) : setup_postdata( $post );
$sub_category = get_the_category($post->ID);
//echo $sub_category[0]->name;
$sub_category_name = $sub_category[0]->name;
$class_type = “type1”;
switch(
$sub_category[0]->term_id){
case ’80’:$class_type = “type1”; // 만난 사람들
break;
case ’82’:$class_type = “type2”; // 수공업
break;
case ’83’:$class_type = “type3”; // 응답
break;
case ’84’:$class_type = “type4″; //문방구 }
?>
< li > < a href=”< ? php the_permalink(); ? >” title=”<? php the_title(); ? >”> < /a> < /li>
<? php
endforeach;
} ? >
디비를 바로 수정 해도 되는 지…
카테고리정보가 어느 테이블에 저장되어 있는 지 못 찾겠네요….
어떻게 해결해야 할지 조언 부탁드립니다.
카테고리 지정할 때 부모카테고리 선택을 해제 하고 수정하니 제대로 나오네요…
초보라 시행 착오가 많네요…^^’;;;