The following snippet will let you WordPress recursive page listing.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | function pagesRecursive($parentId, $lvl){ $args=array('child_of' => $parentId, 'parent' => $parentId); $pages = get_pages($args); if ($pages) { $lvl ++; foreach ($pages as $page) { print "<div style='margin-left:".($lvl * 30)."; border:solid 1px #000; margin-bottom:10px; '>"; print $page->ID."<br>"; print $page->post_date."<br>"; print $page->post_title."<br>"; print $page->post_content."<br>"; print "</div>"; pagesRecursive($page->ID, $lvl); } } } pagesRecursive(20, 0); |