WordPress Submenus or subpages how to list child page links

From: http://codex.wordpress.org/Template_Tags/wp_list_pages
To list a child page menu while only on the parent page, in other words to display a submenu:

Put this inside the the_post() section of the page.php template of your WordPress theme after the_content(), or put it in a copy of the page.php template that you use for pages that have sub-pages (index.php is the template you want if you are using pages instead of posts):

<?php  $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');  if ($children) { ?>  <ul>  <?php echo $children; ?>  </ul>  <?php } ?>

A problem with WordPress 2.7 not showing submenus:
from: http://wordpress.org/support/topic/238967
There seems to be major issues with adding submenus in custom top-level menus with WPMU 2.7 I have a set of plugins that need to go into their own top-level menu, so one of the plugins does nothing but create the menu structure for the others. This used to work fine till 2.6.5 (the last stable version), but stopped working in the release 2.7

The problem is that the link that’s generated for the submenu is not of the form
but instead, it’s of the form

As a result, even though the menu items are added, clicking on them leads to a 404. This breaks several other plugins (one that I could immediately spot is Buddypress Friends plugin).

I searched in the forums, and found posts about similar behaviour for others as well, but it seemed unresolved (or had inexplicably resolved itself). After tracing through the code, it seems that there’s a little bug in the code in menu-header.php (fixing it worked for me – my plugins as well as the others started working).

on line 122:
$parent_exists = (!$admin_is_parent && file_exists(WP_PLUGIN_DIR . “/{$item[2]}”) && !is_dir(WP_PLUGIN_DIR . “/{$item[2]}”) ) || file_exists($item[2]) || ( file_exists( WPMU_PLUGIN_DIR . “/{$item[2]}” ) && ! is_dir( WPMU_PLUGIN_DIR . “/{$item[2]}” ) );

should be:

$parent_exists = !$admin_is_parent && ((file_exists(WP_PLUGIN_DIR . “/{$item[2]}”) && !is_dir(WP_PLUGIN_DIR . “/{$item[2]}”) ) || file_exists($item[2]) || ( file_exists( WPMU_PLUGIN_DIR . “/{$item[2]}” ) && ! is_dir( WPMU_PLUGIN_DIR . “/{$item[2]}” ) ));

(note the different grouping of conditions).
Like I said, this fixed the problem for me, and doesn’t seem to break anything (at least nothing that I’ve found yet). I’m posting this so that others can also take a look. Hopefully, it will help others with similar issues.

Listing Subpages of Subpages:

Leave a comment