Skip to content

Instantly share code, notes, and snippets.

@sblmasta
Last active December 31, 2015 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sblmasta/7987106 to your computer and use it in GitHub Desktop.
Save sblmasta/7987106 to your computer and use it in GitHub Desktop.
WordPress navigation generator
<?php
$menu_name = 'main-primary-menu';
$locations = get_nav_menu_locations();
$menu = wp_get_nav_menu_object( 45 ); //wpisane na sztywno ID lokalizacji menu
$menu_items = wp_get_nav_menu_items($menu->term_id);
echo '<ul id="menu-'.$menu_name.'">';
echo '<li class="current_page_item"><a href="'.get_bloginfo('url').'">Strona Główna</a></li>';
foreach ( (array) $menu_items as $key => $menu_item )
{
$title = $menu_item->title;
$url = $menu_item->url;
$slug = 'hover-data-'.sanitize_title($title);
$li_class = 'big_dropdown'; //klasa elementu <li>
echo '<li class="'.$li_class.'" data-content="'.$slug.'"><a href="'.$url.'">'.$title.'</a></li>';
}
echo '</ul>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment