<navclass="submenu"><divclass="wrapper"><?php// SUBMENU - active page's children (or siblings if on child page)// If no ancestors, use current page. Else use last ancestor$section_id=empty($post->ancestors)?$post->ID:end($post->ancestors);// Get theme menu locations$locations=get_nav_menu_locations();// Navigation location/name$menu=wp_get_nav_menu_object($locations['main-menu']);// ie 'main-menu' is our nav menu's name// Submenu items of identified section$menu_items=wp_get_nav_menu_items($menu->term_id,array('post_parent'=>$section_id));if(!empty($menu_items)):// Hamburger toggle ?><buttonclass="hamburger hamburger--spin toggle-submenu"type="button"aria-label="Menu"aria-controls="navigation"><spanclass="hamburger-box"><spanclass="hamburger-inner"></span></span></button><?php// Output menu items ?><ulclass="section-submenu container nav"><?phpforeach($menu_itemsas$menu_item):?><li><ahref="<?phpecho$menu_item->url;?>"><?phpecho$menu_item->title;?></a></li><?phpendforeach;?></ul><?phpendif;?></div></nav>
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.