Skip to content

Instantly share code, notes, and snippets.

View heshaShawky's full-sized avatar

Hesham Shawky heshaShawky

View GitHub Profile
@heshaShawky
heshaShawky / menu-nav.php
Last active May 26, 2017 09:55
Custom wordpress navigation with custom icons for each element using fontawesome
<?php
// Get the nav menu based on $menu_name (same as 'theme_location' or 'menu' arg to wp_nav_menu)
// This code based on wp_nav_menu's code to get Menu ID from menu slug
$menu_name = 'primary';
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);
$menu_list = '<ul class="nav list-unstyled nav-stacked" role="tablist" id="menu-' . $menu_name . '">';
foreach ( (array) $menu_items as $key => $menu_item ) {
$title = $menu_item->title;