Strip away CSS selector attributes from wp_nav_menu

Most of the time WordPress generates CLASS and ID attributes that only clutters down your beautiful markup, this function removes those unused selectors and superfluous markup.

Use it together with filters, as shown below. Change wp_nav_menu to whatever filter you want to strip, and add this to functions.php.

Code Snippet:

function remove_css_selector_attributes($input) {
    return preg_replace('/ (id|class)=\"(.*?)\"/', '', $input);
add_filter( 'wp_nav_menu', 'remove_css_selector_attributes' );

Posted in Pure hacks