- This topic has 9 replies, 2 voices, and was last updated 2 years ago by Ying.
-
AuthorPosts
-
March 26, 2022 at 8:49 am #2168161tolis
hello, i have put cart icon and search icon to the secondary menu which is above primary menu but on mobile i have hide the secondary menu..how i can display the cart icon and search icon to mobile in primary menu without losing on desktop the icons in secondary menu..
Thanks in regards.
March 26, 2022 at 10:51 am #2168229YingStaffCustomer SupportHi Tolis,
Can you try activate the navigation search at customizer > layout > primary navigation, and activate the cart at customizer > layout > Woocommerce?
Once it’s done, do the cart and search icon appear in the primary navigation?
If so, please link us to your site, we can add some custom CSS to hide them on desktop.
If not, can you share the code of adding cart and search to secondary navigation here?
March 26, 2022 at 11:11 am #2168244tolisi have shared you the link. on desktop i am ok, just want to show the cart and search in mobile menu right to the logo ( not in off canvas menu)
Thanks
March 26, 2022 at 11:16 am #2168254YingStaffCustomer SupportCan you try the solution I mentioned in my last reply?
March 26, 2022 at 11:21 am #2168258tolisyeah i have them activated
March 26, 2022 at 11:27 am #2168264YingStaffCustomer SupportSo it doesn’t work.
Can you share the code you are using which adds the icons to secondary navigation?
March 26, 2022 at 11:37 am #2168268tolisthe code is
add_filter( ‘generate_woocommerce_menu_item_location’, ‘tu_move_menu_cart_item’ );
function tu_move_menu_cart_item() {
return ‘secondary’;
}and
add_action( ‘wp’, function() {
if ( ‘enable’ === generate_get_option( ‘nav_search’ ) ) {
remove_action( ‘generate_menu_bar_items’, ‘generate_do_navigation_search_button’ );
add_action( ‘generate_secondary_menu_bar_items’, ‘generate_do_navigation_search_button’ );remove_action( ‘generate_inside_navigation’, ‘generate_navigation_search’ );
add_action( ‘generate_inside_secondary_navigation’, ‘generate_navigation_search’ );
}
}, 20 );March 26, 2022 at 2:59 pm #2168364YingStaffCustomer SupportTry change your codes to this:
add_filter( 'generate_woocommerce_menu_item_location', 'tu_move_menu_cart_item' ); function tu_move_menu_cart_item() { if (!wp_is_mobile()) { return 'secondary'; } return 'primary'; } add_action( 'wp', function() { if ( 'enable' === generate_get_option( 'nav_search' ) && !wp_is_mobile() ) { remove_action( 'generate_menu_bar_items', 'generate_do_navigation_search_button' ); add_action( 'generate_secondary_menu_bar_items', 'generate_do_navigation_search_button'); remove_action( 'generate_inside_navigation', 'generate_navigation_search' ); add_action( 'generate_inside_secondary_navigation', 'generate_navigation_search' ); } }, 20 );
March 27, 2022 at 2:15 am #2168568tolisyeah it worked thank you very much ๐
March 28, 2022 at 9:41 am #2170124YingStaffCustomer SupportYou are welcome ๐
-
AuthorPosts
- You must be logged in to reply to this topic.