Skip to content

Instantly share code, notes, and snippets.

@jdcauley
Created January 9, 2014 21:29
Show Gist options
  • Save jdcauley/8342397 to your computer and use it in GitHub Desktop.
Save jdcauley/8342397 to your computer and use it in GitHub Desktop.
Add Menu Description to WP Nav
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' . "<span>{$desc}</span><", $item_output);
}
@qwave
Copy link

qwave commented Jul 9, 2015

Thank for this!
But how to insert description before title?
My menu looks like this: Image -> Title. I need Image -> Description -> Title and this function made: Description -> Image -> Title

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment