Back in July 2011, I wrote about cleaning up the navigation menus in WP. In that post, I provided code to reduce classes on navigation menu
<li>s and make the IDs a little more semantic and consistent across installations. I also mentioned that maybe some day I would convert this into a plug-in, if people seemed interested. And people seemed interested.
So, here it is, my Navigation Menu IDs & Classes plug-in for WP, downloadable right from the WP Plug-in Repository.
And here are a couple screenshots of the plug-in in action…
Specifically, note the change from:
<li id="menu-item-677" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-677">
As well as the change from:
<li id="menu-item-676" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-56 current_page_item menu-item-676">
<li id="nav-home" class="current_page_item">
I think that’s pretty darned nifty! Of course, you could always use CSS that combines pairings of
<body> IDs/classes and
<li> IDs/classes, thus making even
class="current_page_item" unnecessary, but I have see those CSS combination selectors get pretty out of control, depending on the size of the site you’re working on.
Anyhow, there it is, folks, love to hear what you think about it, and if anyone can find a way to get the page IDs into the standard menus. And now that I think about it, IDs might be a bad idea, because multiple menus that contain the same links, would actually conflict…
Hmmm… Thought for another day…