Description is added in the menu link, help!
-
I’m using this code in functions.php to get the menu-description to work.
function add_description_nav_menu( $item_output, $item ) {
$description = $item->post_content;
if (‘ ‘ !== $description )
return preg_replace( ‘/(<a.*?>[^<]*?)</’, ‘$1’ . ‘<p class=”menu-description”>’ . $description . ‘</p><‘, $item_output);
else
return $item_output;
}
add_filter( ‘walker_nav_menu_start_el’, ‘add_description_nav_menu’, 10, 2 );Something is very wrong, but I dont know what because I’m new to php. The description is acting like a link. I also get a space between one of my menu-title and its submenu. Is there someone who can help me with this code?
Got the code from this site: https://wpsites.net/wordpress-themes/adding-a-description-below-each-nav-menu-item/
- The topic ‘Description is added in the menu link, help!’ is closed to new replies.