Skip to content

Instantly share code, notes, and snippets.

@elicus
Last active January 17, 2019 13:44
Show Gist options
  • Save elicus/942ca3f9dd63b0e39184fa6881a6dd57 to your computer and use it in GitHub Desktop.
Save elicus/942ca3f9dd63b0e39184fa6881a6dd57 to your computer and use it in GitHub Desktop.
Add description to Divi theme menu items
<?php
function nav_menu_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', 'nav_menu_description', 10, 4 );
?>
@elicus
Copy link
Author

elicus commented Jan 17, 2019

CSS
span.menu-item-description {
display: block;
color: #999999;
}

#top-menu li {
vertical-align: top;
}

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