ancestors){
$parent = $wpdb->get_var( "SELECT post_parent from wp_posts WHERE ID=".$post->ID );
while($parent != FALSE){
//----------------------------------- make the pages listed in the exludes menu not show ---------------------------------
if(isset($exclude)){
foreach( $exclude as $e ){
if( $parent == $e ){
$toggle = 'yes';
}
}}
if( $toggle == 'yes' ){
$toggle = '';
} else {
//--------------------------------------------------------------------------------------------------------------------
$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( $instance['include_parent'] == 'checked' ){
wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$p);
echo '
';
}
//=----------------------------------- makes the link list -----------------------------------------
foreach($result as $pageID){
wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$pageID->ID);
if($pageID->ID == $post->ID or $pageID->ID == $post->post_parent or in_array($pageID->ID, $post->ancestors) ):
echo '