Skip to content

Instantly share code, notes, and snippets.

@zachakbar
Created March 6, 2018 21:44
Show Gist options
  • Save zachakbar/49a20f5a4c1446ff49a5ed29264a4faf to your computer and use it in GitHub Desktop.
Save zachakbar/49a20f5a4c1446ff49a5ed29264a4faf to your computer and use it in GitHub Desktop.
Add descriptions for menu items
/************************************************************************/
/* ADD DESCRIPTION TO MENU
/************************************************************************/
// Add description to navigation
function prefix_nav_description( $item_output, $item, $depth, $args ) {
if ( !empty( $item->description ) ) {
$item_output = str_replace( $args->link_after . '</a>', '<span class="menu-item-description">' . $item->description . '</span>' . $args->link_after . '</a>', $item_output );
}
return $item_output;
}
add_filter( 'walker_nav_menu_start_el', 'prefix_nav_description', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment