Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save christophercochran/2844529 to your computer and use it in GitHub Desktop.
Save christophercochran/2844529 to your computer and use it in GitHub Desktop.
Adds Menu Description to Wordpress Menu with the walker_nav_menu_start_el filter.
add_filter( 'walker_nav_menu_start_el', 'gt_add_menu_item_description', 10, 4);
function gt_add_menu_item_description( $item_output, $item, $depth, $args ) {
$desc = __( $item->post_content );
return preg_replace('/(<a.*?>[^<]*?)</', '$1' . "<small class=\"nav-desc\">{$desc}</small><", $item_output);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment