Skip to content

Instantly share code, notes, and snippets.

@ajmorris
Last active August 6, 2018 18:08
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 ajmorris/60255a31d90dcab6efc7d6abd81d46ec to your computer and use it in GitHub Desktop.
Save ajmorris/60255a31d90dcab6efc7d6abd81d46ec to your computer and use it in GitHub Desktop.
making the description display for menu items with description filled out
<?php
// Adds the descriptions to menu output
function prefix_nav_description( $item_output, $item, $depth, $args ) {
if ( !empty( $item->description ) ) {
$item_output = str_replace( $args->link_after . '</a>', '<p class="menu-item-description">' . $item->description . '</p>' . $args->link_after . '</a>', $item_output );
}
return $item_output;
}
add_filter( 'walker_nav_menu_start_el', 'prefix_nav_description', 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment