2012-06-19 2 views

답변

0

이 시도 :

<?php 
    if($post->post_parent) { 
    $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); 
    $titlenamer = get_the_title($post->post_parent); 
    } 

    else { 
    $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0"); 
    $titlenamer = get_the_title($post->ID); 
    } 
    if ($children) { ?> 

    <h2> <?php echo $titlenamer; ?> </h2> 
    <ul> 
    <?php echo $children; ?> 
    </ul> 

<?php } ?> 

이 코드는 현재 페이지의 모든 하위 페이지를 표시합니다. 따라서 레벨 3에있을 때 레벨 4 하위 페이지가 있으면 표시합니다.

Refer this Codex section

0

이 기능을 시도 할 수 있습니다 :

function getPages($pid=0) { 
    global $wpdb; 
    $pages = $wpdb->get_results($sql = " 
     SELECT * 
     FROM $wpdb->posts 
     WHERE 
      post_type = 'page' && 
      post_status = 'publish' && 
      post_parent = $pid 
     ORDER BY menu_order 
    "); 
    return $pages; 
} 

$의 PID는 경우 세 번째 탐색 수준 페이지 ID를 부모 ID를합니다.

관련 문제