Custom Menus Description Stripping HTML Tags

(Untested). But if you want to use HTML in the description, then you shouldn’t use:

`esc_html( $item->description )`

Try removing the esc_html as this escapes the HTML. (Or better still use wp_kses instead to only allow certain tags.).

So you want

$description = ( ! empty ( $item->post_content ) and 1 == $depth )
    ? '<span class="nav_desc">' .$item->post_content . '</span>' : '';

And you still want the remove_filter( 'nav_menu_description', 'strip_tags' );, but the cus_wp_setup_nav_menu_item function is unnecessary.

Although I don’t in the above example, I would recommend using wp_kses.

Leave a Comment