Update side navigation
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 12 Nov 2015 20:33:05 +0000 (15:33 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 12 Nov 2015 20:33:05 +0000 (15:33 -0500)
For the dog license page which was a leaf node. Fixed this so if you
have any nav item in more than once it will grab the second menu parent for
the side name.

functions.php

index 5877e6b..c3a77a3 100644 (file)
@@ -134,7 +134,7 @@ function glm_side_menu($mobile = false) {
     global $post;
     $sideMenu = $allMenu = $pageMenuId = array();
     if (($locations = get_nav_menu_locations()) && isset($locations['top-bar'])) {
-        $menu = wp_get_nav_menu_object($locations['top-bar']);
+        $menu       = wp_get_nav_menu_object($locations['top-bar']);
         $menu_items = wp_get_nav_menu_items($menu->term_id);
         foreach ((array) $menu_items as $key => $menu_item) {
             $sideMenu[$menu_item->menu_item_parent][] = $menu_item;
@@ -144,9 +144,11 @@ function glm_side_menu($mobile = false) {
             }
         }
         if (count($pageMenuId) > 1) {
+            $thisPageMenuId = (isset($pageMenuId[1])) ? $pageMenuId[1]->ID : 0;
+            $thisPageMenuParent = (isset($pageMenuId[1])) ? $pageMenuId[1]->menu_item_parent : 0;
             foreach ($pageMenuId as $men) {
                 if (isset($sideMenu[$men->ID]) && !empty($sideMenu[$men->ID])) {
-                    $thisPageMenuId = $men->ID;
+                    $thisPageMenuId     = $men->ID;
                     $thisPageMenuParent = $men->menu_item_parent;
                 }
             }