Skip to content

Instantly share code, notes, and snippets.

@GaryJones
Created January 29, 2012 11:46
Show Gist options
  • Save GaryJones/1698437 to your computer and use it in GitHub Desktop.
Save GaryJones/1698437 to your computer and use it in GitHub Desktop.
Selectively remove title attributes on Genesis-created (vestigial) menus
<?php
// Optionally remove from WP custom menus too
add_filter( 'wp_nav_menu_items', 'child_remove_primary_navigation_titles', 10, 2);
add_filter( 'genesis_nav_items', 'child_remove_primary_navigation_titles', 10, 2 );
/**
* Remove all title attributes on Genesis-created navigation menus in the primary location.
*
* @author Gary Jones
* @link http://code.garyjones.co.uk/remove-genesis-navigation-titles#being-selective
*
* @param string $menu HTML markup of menu list items.
* @param array $args Menu arguments associative array.
*
* @return string HTML markup.
*/
function child_remove_primary_navigation_titles( $menu, $args ) {
if ( 'primary' == $args['theme_location'] )
$menu = preg_replace( '/ title="[^"]*"/', '', $menu );
return $menu;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment