Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WP List Single Level Menu with some nice options.
// LIST MENU
function hg_get_list_menu( $menu_location = 'footer', $delimiter = "•", $class_name = "nav", $wrapper = "div", $echo = true )
{
$menu_locations = get_nav_menu_locations();
$menu_items = (array) wp_get_nav_menu_items( $menu_locations[ $menu_location ] );
$num_menu_items = count($menu_items);
if($num_menu_items >= 1)
{
$rtn .= "<{$wrapper} class=\"{$class_name}\">\n";
$end_of_loop = $num_menu_items - 1;
foreach( (array) $menu_items as $c => $menu_item )
{
$add_target = ($menu_item->target) ? " target='{$menu_item->target}'" : "";
$rtn .= " <a href=\"{$menu_item->url}\"{$add_target}>{$menu_item->title}</a>";
if($c < $end_of_loop) { $rtn .= " $delimiter \n"; }
}
$rtn .= "</{$wrapper}>\n";
}
if($echo) echo $rtn;
else return $rtn;
}
@halgatewood

This comment has been minimized.

Copy link
Owner Author

@halgatewood halgatewood commented Jul 2, 2013

I want to add highlighting one day. For now I am using this mostly in footers where it doesn't matter as much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment