나는 모든 것을 해결하려고 노력했지만 온종일 고생하고 있습니다. 나는 부모 게시물을 가질 수있는 상태에 이미 내 WordPress 게시물을 가지고 있습니다. 수행 : WordPress Loop에서 챕터 번호가 필요합니다.
add_action('init', 'add_hierarchy_to_posts'); function add_hierarchy_to_posts() { add_post_type_support('post', 'page-attributes'); $obj = get_post_type_object('post'); $obj->hierarchical =true; remove_theme_support('post-formats'); }
내 게시물
1. 소개
2. 주제 대단한 먹으 렴 있도록 장에서 numerized 필요
2.1 왜 큰
2.2 왜 주제
2.2.1 양호함
2.2.2 악화
최선의 경우 2.2.2.1
3. 끝
문제는 절이을 계산하는 방법, 지금이다. 함수 원경 여기이며 포스트 ID 전에
global $chapter,$subchapter,$subchapter1,$subchapter2,$depper; function is_child_of($postID) { global $post; $ico=$post->post_parent; return $ico; } function find_out_chapter_number($id){ global $chapter,$subchapter,$subchapter1,$subchapter2,$subchapter3,$depper; if(is_child_of($id)==0){ $chapter++; $subchapter=0; } else if(is_child_of($id)==$depper){ $subchapter++; } $depper=$id; $ico=is_child_of($id); //$id. " - ".$ico." - ". return $chapter.".".$subchapter.".".$subchapter1.".".$subchapter2; }
은 $ depper 변수 저장
3.1 3.2 1.0 2.0
3.0 이상
를 생성한다.
나는 그것을 더 깊게 필요로하고 재귀와 함께 그 무언가를 생각했지만 나는 모른다.
이 함수는
$kapitel = find_out_chapter_number(get_the_ID());으로 워드 프레스 루프에서 호출되고 the_title() 앞에 반향됩니다.
Google에이 작업 링크를 표시 할 수 있습니까? – designtocode
워드 프레스 플러그인 위젯으로 다운로드 http://www62.zippyshare.com/v/38624584/file.html – theode