News Feed
Jobs Feed
Sections




News Archive
SitePoint PHP Blog:
How to Tidy Your WordPress Menu HTML
January 26, 2011 @ 09:37:59

On the SitePoint PHP blog today there's a new post from Craig Buckler for the WordPress users out there. The HTML that this popular blog/CMS tools spits out can sometimes be not-so-semantic. Craig shares a tip on cleaning up one aspect of it - the methods returning lists for menus or sitemaps.

love WordPress. I also love clean semantic HTML. Unfortunately, several of the standard WordPress theme functions return code that is a little untidy. For me, the primary culprits are wp_list_pages() and the newer wp_nav_menu(); both return an unordered list of page links.

He gives an example of a sample list generated by wp_nav_menu() that's full of badly formatted and unnecessary elements. To help fix the issue, he shares his regular expression-based call to strip out things like extra tabs, empty classes and all title attributes. Obviously you can customize this as you need, but it's a good start towards something that's a bit cleaner and up to code.

0 comments voice your opinion now!
wordpress tidy html output pregreplace regularexpression menu


blog comments powered by Disqus

Similar Posts

Community News: HTML2PHP - Transformation Tool

JSLabs Blog: Scaling PHP

Sebastian Bergmann\'s Blog: More Work on Reporting in PHPUnit 3

Leon Kilat\'s Blog: How to edit Wordpress themes using Dreamweaver

SitePoint PHP Blog: Pretty Blue Screen


Community Events









Don't see your event here?
Let us know!


object framework development opinion code tool zendframework2 community interview api release composer conference introduction example functional event testing language podcast

All content copyright, 2013 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework