All pastes #219704 Raw Edit

Untitled

public php v1 · immutable
#219704 ·published 2006-10-24 20:40 UTC
rendered paste body
<div id="sub_nav"><ul><?php$page = $wp_query->post;$parent_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE ID = '$page->post_parent;'");if(!$parent_id) {   $parent_id = $post->ID;} else {   $has_parents = TRUE;} ?><?phpif (!$has_parents) {// i'm the top level page, so display 1 level of navigation only.$my_depth = '-1'; wp_list_pages("title_li=&child_of=".$parent_id."&sort_column=menu_order&depth=$my_depth");} else {// i'm not the top level, so i need to see if i have childrenif(wp_list_pages("child_of=".$post->ID."&echo=0")) {   $my_depth = '0';wp_list_pages("title_li=&child_of=".$parent_id."&sort_column=menu_order&depth=$my_depth");} else {// no child pages $parent_has_parent_id = $wpdb->get_var("SELECT post_parent FROM $wpdb->posts WHERE ID = '$parent_id;'");   if ($parent_has_parent_id) {      $my_depth = '0';wp_list_pages("title_li=&child_of=".$parent_has_parent_id."&sort_column=menu_order&depth=$my_depth");   } else {      $my_depth = '-1';wp_list_pages("title_li=&child_of=".$parent_id."&sort_column=menu_order&depth=$my_depth");   }}}?>