Menu of childern

Normally used in sidebar

function list_pages_shortcode( $atts ) {
    // Basic shortcode markup
    extract( shortcode_atts( array(
        'post_parent' => false,
        'id' => '',
        'depth' => '',
    ), $atts ) );
 
    //If the post parent attribute isn't specified, use the current post's ID
    if ( ! $post_parent ) {
    global $post;
        if ( is_object( $post ) ) {
        
            if(empty($id)) { 
            $post_parents = get_post_ancestors( $post->ID );
            $post_parent = $post_parents[0];
            }else{ $post_parent = $id; }
            
            if(empty($depth)) { $depth = 2; }
            
            
        } else {
            return false;
        }
    }
    
    if ($post_parent == "self") { $post_parent = $post->ID; }

 
    //Build the arguments - we want the child of the post_parent
    $args = array(
        'depth'        => $depth,
        'child_of'     => $post_parent,
        'title_li'     => $title,
        'echo'         => 0,
        'sort_column'  => 'menu_order, post_title'
        );
 
    // if there is no title lets barf up the wordpress pages instead
    if ( empty( $title ) ) {
        return "<ul>" . wp_list_pages( $args ) . "</ul>";
    } else {
        return wp_list_pages( $args );
    }
}
add_shortcode( 'list_subpages', 'list_pages_shortcode' ); 
Comments