It is best to loop through all the menu items so you can get them separately, like this. This will give you the possibility to add classes to both your ul and your li items.
<?php $myMenu = get_nav_menu_locations();
// 'main-menu' is the name of your menu, you can find this under 'menu' in the Dashboard of your WordPress site
$menuID = $myMenu['main-menu'];
$mainNav = wp_get_nav_menu_items($menuID);
?>
<ul>
<?php foreach ($mainNav as $navItem): ?>
<li>
<a href="https://wordpress.stackexchange.com/questions/288486/<?php echo $navItem->url; ?>"
title="<?php echo $navItem->title; ?>">
<?php echo $navItem->title; ?>
</a>
</li>
<?php endforeach; ?>
</ul>
Related Posts:
- Hide Login information in Account settings in Buddy Boss
- Programmatically (PHP) get the nr. of items in the primary navigation menu
- Add clickable arrows to parent menu items with children elements e.g. with
- Sticky menu for WP custom menubars
- Position a hard-coded menu item
- How to add active state to the navigation links?
- Customize Widget Navigation
- Custom menu not showing even though it shows as being registered?
- Current menu item highlights wrong
- remove or hide Link Relationship (XFN) form Menus tab
- removing extra mobile menu from the header
- Custom Menu (only showing direct cildren) ACF not showing
- Add custom html to last sub-menu item
- wp_nav_menu() custom container and container_id
- Show a WP 3.0 Custom Menu in an HTML Select with Auto-Navigation?
- global menus made from master site’s custom menus wpmu network
- Adding Custom Link anchors in the top menu that points to specific sections of the site home page
- wordpress custom walker for thumbnails with custom menu
- Extend walker – navigation, adding data attribute to a tag
- Change default status and replace the icon for an hamburger menu
- simple expandable vertical menu, java script problem
- wp_nav_menu doesn’t generate parent/ancestor classes
- Create a Custom menu item fetched by Product Categories and Sub Categories
- Can this navigation be done easily in WordPress?
- wp_nav_menu google analytics event tracking
- Only append custom classes to nav menu items
- Outputting Page Content in Two Places
- How to extend nav-menu-item-control data in Appearance > Customize?
- Using Shortcodes in WP-Menus in WP 3.1 (via nav_menu_objects)?
- How can I get the page url slug when ‘post_name’ returns an id?
- Multiple menu items highlighted
- Adding all sub-pages to the menu manager
- add JS to multiple plugin admin pages
- Putting tag outside tag on generated Menu
- Separator for custom nav menu
- URLs and navigation in custom themes
- How to create left and right menu with logo center in a custom theme?
- How Do I Remove The Right Hand Block On The Main Header?
- Adding posts to custom menu [closed]
- Alphabetical Custom Menu
- Sub menu indicator that links to sub menu
- Navigation label for page in custom theme
- Help with walker for nav
- Using my WordPress menu on another platform
- WPML Plugin Not displaying multilingual Menus
- Using _s theme, menu changes do not affect header menu
- how to display a specific wordpress menu?
- Create a url structure for my blogs based on categories and sub-cats
- Looking replicate static HTML Menu into WordPress Dynamic Menu [closed]
- How to remove footer from just homepage
- Custom font size nav bar
- Stop Expansion of Top Level Menu in the WordPress Admin Sidebar
- Insert menu with a custom walker into page / post body using shortcode?
- Implement a Walker with custom object rather than WordPress database object
- add another html tag after li element in wp_nav_menu
- How can I tag a menu item as visited for each unique user?
- How do I create a root link in wordpress to a PDF file?
- How can i create menu like in the example?
- WordPress custom dropdown listings
- How to request container_class from wp_nav_menu
- Menu not appearing in custom theme
- How can i display custom menu in sidebar?
- How to have multiple WordPress Menus
- Missing current_page_item in custom menu
- How would I make a function to dynamically determine if user is logged to change navigation menu text?
- WordPress menu: How to make www.link.com/#name never contain current_page_item class?
- How to retain visual breadcrumbs w/ tricky URL structure? Custom post template?
- Add custom border across footer widget area
- How to get Previous Visited Page Information
- Custom CSS Nav Menu Style Not Being Applied
- Add producthunt badge to wordpress menu
- Woocommerce custom “My Account” Tab – Add Save button
- How could I change contact details in the footer?
- Adding a drop-down (select tag) option under Menu Settings in WordPress Admin
- How to add a template – so that i can choose a different menu for some pages
- clickable toggle menu, help
- How to create custom post type selection to nav menu
- Duplicate Header and Footer
- Help needed creating a custom Hamburger menu in header
- Menu selection for header
- How to create a custom menu for specific user
- How to customize WordPress vertical menu?
- Creating a dynamic URL for an external link inside content
- My connecting URL form in html to PHP does not work
- User WordPress menu in custom page
- Adding images to anchors in the list created and fetched with wp_nav_menu
- Multiple Owl Carousels on the same page with navigation problem
- generate a static copy of the website footer html
- how to hard link to the posts page?
- Creating a Treeview Listing of a Directory
- Show Header When Not In Iframe
- How do I display entries in the top menu based on conditions selected in the sidebar menu?
- Buddypress: New Tab and Page (Members Profile) [closed]
- How to work around the bug which prevents custom menus from being deleted?
- Class .current-menu-item in custom menu Walker
- customize footer widgets area
- menu customization
- How to move menu next to left of the search box?
- Custom CSS File wont work on second Page
- How can I structure my pseudo footer nav code with wordpress codex code?