[resolved] Description is added in the menu link, help! (2 posts)

  1. Rugado
    Posted 2 years ago #

    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);
    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: http://wpsites.net/wordpress-themes/adding-a-description-below-each-nav-menu-item/

  2. Rugado
    Posted 2 years ago #

    I found the mistake!

Topic Closed

This topic has been closed to new replies.

About this Topic