excluding menu items with parents from the off glm_page_menu function for the off...
authorAnthony Talarico <talarico@gaslightmedia.com>
Fri, 14 Oct 2016 13:49:18 +0000 (09:49 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Fri, 14 Oct 2016 13:49:18 +0000 (09:49 -0400)
functions.php

index 96b77ee..dd2864b 100644 (file)
@@ -315,15 +315,18 @@ function hm_get_template_part( $file, $template_args = array(), $cache_args = ar
             return $data;
     echo $data;
 }
-// add the name of the appearance as the parameter to create a menu based on its subpages
+// add the name of the appearance menu as the parameter to create a menu based on its subpages
 function create_offcanvas_menu($menu_name){
     if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[$menu_name] )) {
         $menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
         $menu_items = wp_get_nav_menu_items($menu->term_id);
     } 
     foreach ( $menu_items as $menu_item ) {
-        $page_ids[] = get_post_meta( $menu_item->ID, '_menu_item_object_id', true );
+        if ( !$menu_item->menu_item_parent ) {
+            $page_ids[] = get_post_meta( $menu_item->ID, '_menu_item_object_id', true );
+        }
     }
+    print_r($page_ids);
     glm_page_menu(0, 'left-off-canvas-list',$page_ids);
 }
 ?>