WordPress hack: disabling showing page children


I was working on my dept 56 pages when I discovered that all child pages of a top level page would be displayed in the sidebar.  I don't really want that.  I want child pages to be linked from the top level page only.  That way the hierarchy isn't stuffed into the sidebar making it way larger than it should be.  

I dug around a little in the WP code and found that the function _page_level_out() in wp-includes/template-functions-post.php has a bit of code that looks like this:

if ( isset($cur_page['children']) && is_array($cur_page['children']) ) {
   $new_depth = $depth + 1;

   if ( !$args['depth'] || $depth < ($args['depth']-1) ) {
      $output .= "$indent<ul>\n";
      $output .= _page_level_out($page_id, $page_tree, $args, $new_depth, false);
      $output .= "$indent</ul>\n";
   }
}


If I comment this out, the children don't show up in the sidebar.  Very cool.  It's a hack and there really ought to be a programmable (re: argument based call) that can disable this, but I just needed it turned off for now.  And no, I haven't dug through the addons for WP to see if anyone has written a plugin for this functionality.  I don't know how the plugin architecture works (haven't dug into that – too many other things to do) so I'm not sure how it might be implemented.  For my purposes, this hack works fine.