Advertisement
Guest User

Untitled

a guest
Jun 12th, 2012
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. // Generate page tree
  2. function purplepastels_page_tree($this_page) {
  3. $pagelist = '';
  4. if( !$this_page->post_parent ) {
  5. $children = wp_list_pages('title_li=&child_of='.$this_page->ID.'&echo=0');
  6. if( $children ) {
  7. $pagelist .= '<li class="current_page_item"><a href="'. get_page_link($this_page->ID) .'">' . $this_page->post_title . '</a>';
  8. $pagelist .= '<ul>' . $children . '</ul>';
  9. $pagelist .= '</li>';
  10. }
  11. }
  12. elseif( $this_page->ancestors ) {
  13. // get the top ID of this page. Page ids DESC so top level ID is the last one
  14. $ancestor = end($this_page->ancestors);
  15. $pagelist .= wp_list_pages('title_li=&include='.$ancestor.'&echo=0');
  16. $pagelist = str_replace('</li>', '', $pagelist);
  17. $pagelist .= '<ul>' . wp_list_pages('title_li=&child_of='.$ancestor.'&echo=0') .'</ul></li>';
  18. }
  19. return $pagelist;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement