Skip to content

Instantly share code, notes, and snippets.

@scott-riley
Created April 1, 2014 12:24
Show Gist options
  • Save scott-riley/9912898 to your computer and use it in GitHub Desktop.
Save scott-riley/9912898 to your computer and use it in GitHub Desktop.
function clean_custom_footer_menus() {
$menu_name = 'footer-links'; // specify custom menu slug
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 = '';
foreach ((array) $menu_items as $key => $menu_item) {
$title = $menu_item->title;
$url = $menu_item->url;
$classes = $menu_item->classes;
$classString = '';
foreach($classes as $class) {
$classString .= $class . ' ';
}
$classString .= $menu->ID;
$menu_list .= '<a href="'. $url .'">'. $title .'</a></li>' ."\n";
}
} else {
// $menu_list = '<!-- no list defined -->';
}
echo $menu_list;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment