Skip to content

Instantly share code, notes, and snippets.

@ocReaper
Created May 13, 2016 14:49
Show Gist options
  • Save ocReaper/10b150d549e61e458641321b7da66ba9 to your computer and use it in GitHub Desktop.
Save ocReaper/10b150d549e61e458641321b7da66ba9 to your computer and use it in GitHub Desktop.
Creating a WordPress menu without a walker class
<?
$locations = get_nav_menu_locations();
$top_menu = wp_get_nav_menu_object( $locations['top'] );
$top_menu_items = wp_get_nav_menu_items( $top_menu->term_id );
if ( is_array( $top_menu_items ) ) :
foreach ( $top_menu_items as $top_key => $top_menu_item ) : ?>
<div class="nav-list-item">
<a href="<?= $top_menu_item->url ?>">
<?= $top_menu_item->title ?>
</a>
</div>
<? endforeach;
endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment