Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #224942

    Hey!

    I have insert a login-widget via Shortcodes in Main Menu that is used as a MegaMenu and it works nice. I insert for this a Shortcode inside the Description-Field. Here you can see what I mean. Just hover the last tab on the right.

    But I think it is better to use this in the submenu. But I can´t get it to work. I´ve made the same as I do in the MainMenu. How can I become a Shortcode to be work in the Submenu? It would be very nice to become a hover-login-form..

    Best regards

    #225324

    Hey Bruno!

    You can use this code, add it to your functions.php file:

    add_filter( 'wp_nav_menu_items', 'my_custom_menu_item', 10, 2 );
    
    function my_custom_menu_item ( $items, $args )
    {	
        $items .= '<li class="menu-item custom-menu-item"><a href="#" rel="nofollow">Asd</a><ul class="sub-menu"><li class="menu-item menu-item-type-post_type menu-item-object-page">'.do_shortcode("[_PUT_YOUR_SHORTCODE_HERE]").'</li></ul></li>';
        return $items;
    }

    If you want it to appear before the search icon, you’d need to add it before line 58 in functions-enfold.php instead.

    Best regards,
    Josue

    #225382

    Hey Josue!

    That works pretty nice, thank you very much! It´s exactly what I need.

    It is possible to hide it for logged in users?

    Thanks a lot!

    Best regards,
    Bruno

    #225383

    Sorry, one more question please. How can I become the submenu responsive? If you make the Browser smaller, the menu items from submenu first switch behind the social media buttons, and afterward below the socials into the main nav field..

    #225392

    Sorry, one more.. The Menu Item apperas in all menus, in Sub Menu, Main Menu and in Socket Menu. But I just need it in the Sub Menu?

    Is it possible to re-arange the Item to another Position?

    Thanks a lot!

    #225548

    Hey!

    This would be the code:

    	function my_custom_menu_item ( $items, $args )
    	{	
    		if(is_user_logged_in()){
    			return $items;
    		}else{
    			if (is_object($args) && $args->theme_location == 'avia'){
    		    	$items .= '<li class="menu-item custom-menu-item"><a href="#" rel="nofollow">Asd</a><ul class="sub-menu"><li class="menu-item menu-item-type-post_type menu-item-object-page">'.do_shortcode("[_PUT_YOUR_SHORTCODE_HERE]").'</li></ul></li>';
    			}
    		}
    	    return $items;
    	}

    Regards,
    Josue

    #225724

    Hey Josue,

    it generates an entry as last menu item in the main nav, but not in the submenu.

    I´ve added this code:

    //own created submenu entry
    add_filter( 'wp_nav_menu_items', 'my_custom_menu_item', 10, 2 );
    function my_custom_menu_item ( $items, $args )
    {   
        if(is_user_logged_in()){
            return $items;
        }else{
            if (is_object($args) && $args->theme_location == 'avia'){
                $items .= '<li class="menu-item custom-menu-item"><a href="" rel="nofollow">Anmelden</a><ul class="sub-menu"><li class="menu-item menu-item-type-post_type menu-item-object-page">'.do_shortcode("[av_sidebar widget_area='Anmelden']").'</li></ul></li>';
            }   
        }
        return $items;
    }

    Here you can see it.

    Regards

    #225746

    Hey!

    Try adding this code to the Quick CSS:

    .custom-menu-item .avia-builder-widget-area.clearfix {
        opacity: 1 !important;
        display: block !important;
        right: 0 !important;
    }
    

    Cheers! 
    Josue

    #225748

    Hey Josue, that works but it isn´t that what i`m need. I´m so sorry !!

    I don´t need this Item where it is. I need it in the bar above.

    #225751

    Change the code to this:

    add_filter( 'wp_nav_menu_items', 'my_custom_menu_item', 10, 2 );
    function my_custom_menu_item ( $items, $args )
    {   
        if(is_user_logged_in()){
            return $items;
        }else{
            if (is_object($args) && $args->theme_location == 'avia2'){
                $items .= '<li class="menu-item custom-menu-item"><a href="" rel="nofollow">Anmelden</a><ul class="sub-menu"><li class="menu-item menu-item-type-post_type menu-item-object-page">'.do_shortcode("[av_sidebar widget_area='Anmelden']").'</li></ul></li>';
            }   
        }
        return $items;
    }

    Regards,
    Josue

    #225806

    Hey Josue,

    that´s it !! Works like a charm. Thanks a lot for your help !

    Best regards
    Bruno

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Shortcodes in Submenu?’ is closed to new replies.