-
AuthorPosts
-
February 17, 2014 at 1:43 pm #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
February 18, 2014 at 5:11 am #225324Hey 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,
JosueFebruary 18, 2014 at 9:28 am #225382Hey 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,
BrunoFebruary 18, 2014 at 9:32 am #225383Sorry, 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..
February 18, 2014 at 9:54 am #225392Sorry, 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!
February 18, 2014 at 4:52 pm #225548Hey!
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,
JosueFebruary 18, 2014 at 8:39 pm #225724Hey 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
February 18, 2014 at 9:26 pm #225746Hey!
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!
JosueFebruary 18, 2014 at 9:33 pm #225748Hey 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.
February 18, 2014 at 9:36 pm #225751Change 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,
JosueFebruary 18, 2014 at 11:15 pm #225806Hey Josue,
that´s it !! Works like a charm. Thanks a lot for your help !
Best regards
Bruno -
AuthorPosts
- The topic ‘Shortcodes in Submenu?’ is closed to new replies.