Include Parent Page />

Include Parent Even With No Children/>

'sidebar-menu', 'description' => 'Creates a menu of all the pages using the child/parent relationship' ); /* Create the widget. */ $this->WP_Widget( 'advanced_sidebar_menu', 'Sidebar Menu', $widget_ops, $control_ops ); } #--------------------------------------------------------------------------------------------------------------------------- // adds the output to the widget area on the page function widget($args, $instance) { global $wpdb; global $p; global $post; //makes the custom menu #-- if the post has parrents if($post->ancestors){ $parent = $wpdb->get_var( "SELECT post_parent from wp_posts WHERE ID=".$post->ID ); //--- If there is a parent of the post set $p to it and check if there is a parent as well while($parent != FALSE){ $p = $parent; $parent = $wpdb->get_var( "SELECT post_parent from wp_posts WHERE ID=".$parent); } } else { #--------- If this is the parent ------------------------------------------------ $p = $post->ID; } $result = $wpdb->get_results( "SELECT ID FROM wp_posts WHERE post_parent = $p AND post_type='page' Order by menu_order" ); #---- if there are no children do not display the parent unless it is check to do so if($result != false || $instance['include_childless_parent'] == 'checked' ){ //Start the menu echo '
'; echo '
'; } } #== /widget() } #== /Class