Skip to content

Instantly share code, notes, and snippets.

@danielcgold
Created September 21, 2016 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielcgold/98e93be1b442f977b0e381caae33e05e to your computer and use it in GitHub Desktop.
Save danielcgold/98e93be1b442f977b0e381caae33e05e to your computer and use it in GitHub Desktop.
[WordPress] add concepts of the description link in all menu items.
<?
function nav_description( $item_output, $item, $depth, $args ) {
if ( $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', 'nav_description', 10, 4 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment