Last active
February 3, 2020 08:49
-
-
Save zoerooney/6471748 to your computer and use it in GitHub Desktop.
Create an arguably cleaner nav menu in WordPress. Version 1 replacing the LI elements in a WordPress menu with SPAN elements, while maintaining classes, etc., while version 2 results in just A elements, still maintaining all the classes, etc. Post: http://zoerooney.com/blog/tutorials/removing-list-items-wordpress-menus/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- The "standard" output format, sanitized/ truncated for legibility, with custom class and link opening in new window --> | |
<div class="menu-upper-menu-container"> | |
<ul id="menu-upper-menu" class="menu"> | |
<li id="menu-item-1" class="twitter menu-item current-menu-item"> | |
<a href="http://twitter.com/username" target="_blank">Blog</a> | |
</li> | |
<li><a><!-- you get the idea ---></a></li> | |
<li><a><!-- ... ---></a></li> | |
</ul> | |
</div> | |
<!-- The output from version 1 --> | |
<nav id="menu-upper-menu" class="menu"> | |
<span id="menu-item-1" class="twitter menu-item current-menu-item"> | |
<a href="http://twitter.com/username" target="_blank">Blog</a> | |
</span> | |
<span><a><!-- you get the idea ---></a></span> | |
<span><a><!-- ... ---></a></v> | |
</nav> | |
<!-- The output from version 2 --> | |
<nav id="menu-upper-menu" class="menu"> | |
<a id="menu-item-1" class="twitter menu-item current-menu-item" href="http://twitter.com/username" target="_blank">Blog</a> | |
<a><!-- you get the idea ---></a> | |
<a><!-- ... ---></a> | |
</nav> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works fine until you have a menu item with 'li' in the title e.g. 'Public'. Replaces the li in the text and Url with an a