Menu description (wordpress)

Display menu description of menu items.

<?php
/**
 * Display menu description of menu items.
 */
add_filter('walker_nav_menu_start_el', function($item_output, $item, $depth, $args) {
    if (!empty($item->description)) {
        $item_output = str_replace('">' . $args->link_before . $item->title, '">' . $args->link_before . '<span class="menu-title">' . $item->title . '</span>' . '<span class="menu-description">' . $item->description . '</span>', $item_output);
    }
    return $item_output;
}, 10, 4);
?>

functions.php

< toolbox