Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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);

This comment has been minimized.

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
You can’t perform that action at this time.