ここはちょっと見せられない

ぜったいぜったい見せられない

簡易メニューツリー

こういう処理大好き

function my_page_tree($id,$depth=0) {

    $args = array(
        "numberposts"   => -1, 
        "post_parent"   => $id,
        "post_type"     => "page",
        "order"         => "asc",
        "post_status"   => "publish",
        );  
    $posts = get_posts($args); 
    if (count($posts) < 1) return;

    echo "<ul class=\"tree$depth\">\n";
    foreach ($posts as $p) {
        echo "<li>\n";
        if ($depth > 0) {
            echo str_repeat("&nbsp;",$depth);
        }
        $url = get_permalink($p->ID);
        echo '<a href="'.$url.'">'.$p->post_title."</a>\n";
        my_page_tree($p->ID,$depth+1);
        echo "</li>\n";

    }
    echo "</ul>\n";

}