Show child pages when on a child page

    Add this code in sidebar.php.this code will help you.                    


                        global $post;
                        $parent_id  = $post->post_parent; 
                        if(!empty($parent_id)){
                        $parent_post=get_post($parent_id);
                        echo '<h1 class="entry-title">'.$parent_post->post_title.'</h1>';
                            echo '<ul>';
                            $children = wp_list_pages('title_li=&child_of=" . $parent_id . "&echo=0');
                            if ($children) {
                            echo $children;
                            echo '</ul>';
                            } 
                         } else { 
                        echo '<ul>';
                        $page =$post->ID;
                        $children = wp_list_pages('title_li=&child_of=" . $page . "&echo=0');
                            if ($children) { 
                            echo $children;
                            } 
                        echo '</ul>';
                        }