// echo '</div>';
// echo '</div>';
+
+/**
+ * glm_side_menu
+ *
+ * Return the Wordpress Menu for location top-bar.
+ * Will return the sub menu for the page based on the lowest level of menu.
+ * So if the page has no sub menu items it will output its siblings and the
+ * parent page as the title. If it has child menu items then it will display
+ * them and itself as the tile.
+ *
+ * @access public
+ * @return void
+ */
function glm_side_menu() {
global $post;
- //echo '<pre>'.print_r($post, true).'</pre>';
- $parents = get_post_ancestors($post->ID);
- $id = (count($parents) > 1) ? $parents[0]: $post->ID;
- $parent = get_page( $id );
- if ($id == 0) {
- $ID = $post->ID;
- } else {
- $ID = $parent->ID;
- }
- //echo '<pre>'.print_r($ID, true).'</pre>';
if (($locations = get_nav_menu_locations()) && isset($locations['top-bar'])) {
$menu = wp_get_nav_menu_object($locations['top-bar']);
$menu_items = wp_get_nav_menu_items($menu->term_id);