Tagged: ,

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #191180

    Hi,

    I’ve tried to add menu descriptions to ENFOLD theme:

    http://i43.tinypic.com/jrsm5t.jpg

    like this way:

    Screenshot

    but ENFOLD shows just nothing of the description. How can I fix it?
    Thanks.

    #191307

    Hey COLORIT!

    You need to add the walker menu. Please hire someone to modify wp_nav_menu and add the walker feature. You can also try this:

    Add this on your functions.php:

    class My_Walker extends Walker_Nav_Menu
    {
    	function start_el(&$output, $item, $depth, $args) {
    		global $wp_query;
    		$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
    
    		$class_names = $value = '';
    
    		$classes = empty( $item->classes ) ? array() : (array) $item->classes;
    
    		$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
    		$class_names = ' class="' . esc_attr( $class_names ) . '"';
    
    		$output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
    
    		$attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';
    		$attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';
    		$attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';
    		$attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';
    
    		$item_output = $args->before;
    		$item_output .= '<a'. $attributes .'>';
    		$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
    		$item_output .= '<span class="walker-sub">' . $item->description . '</span>';
    		$item_output .= '</a>';
    		$item_output .= $args->after;
    
    		$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
    	}
    }

    Go to Quick CSS, add this code:

    .walker-sub {
    	display: block;
    	position: absolute;
    	top: 70px;
    	min-width: 90px;
    	font-size: 10px;
    	color: gray;
    	line-height: 12px;
    }

    Edit header.php, find this code on line 167:

     echo "<nav class='main_menu' data-selectname='".__('Select a page','avia_framework')."' ".avia_markup_helper(array('context' => 'nav', 'echo' => false)).">";
                                    $avia_theme_location = 'avia';
                                    $avia_menu_class = $avia_theme_location . '-menu';
                                    $args = array(
                                        'theme_location'	=> $avia_theme_location,
                                        'menu_id' 			=> $avia_menu_class,
                                        'container_class'	=> $avia_menu_class,
                                        'fallback_cb' 		=> 'avia_fallback_menu',
                                        'walker' 			=> new avia_responsive_mega_menu()
                                    );

    Replace it with:

    
    echo "<nav class='main_menu' data-selectname='".__('Select a page','avia_framework')."' ".avia_markup_helper(array('context' => 'nav', 'echo' => false)).">";
                                    $avia_theme_location = 'avia';
    								$walker = new My_Walker;
                                    $avia_menu_class = $avia_theme_location . '-menu';
                                    $args = array(
                                        'theme_location'	=> $avia_theme_location,
                                        'menu_id' 			=> $avia_menu_class,
                                        'container_class'	=> $avia_menu_class,
                                        'fallback_cb' 		=> 'avia_fallback_menu',
                                        'walker' 			=> $walker
                                    );

    Best regards,
    Ismael

    #191558

    Thanks a lot, Ismael.
    It works perfect with your code as long as the main menu item is not set as “mega menu”.

    I have set the menu items as “mega menu” and now with your code it shows me as “normal menu”, not mega menu.
    Any tips?
    Thanks.

    • This reply was modified 9 months, 1 week ago by  colorit2.
Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Menu descriptions’ is closed to new replies.