- This topic has 12 replies, 3 voices, and was last updated 2 years, 4 months ago by David.
-
AuthorPosts
-
December 13, 2021 at 8:51 am #2047725Reinoud
Hi Generatepress,
My Primary Navigation Menu has 2 rows of items, but in the end of the second row there is plenty of space for the Navigation Search Icon.
However when I turn on the ‘Navigation Search Icon’ the Icon is placed in a new, third row. How can I add this as the last item on the second row?
This is the situation: https://ibb.co/rmH4htN
December 13, 2021 at 2:39 pm #2047975DavidStaffCustomer SupportHi there,
can you share a link to your site where i can see the issue ?
December 13, 2021 at 11:20 pm #2048280ReinoudHi David,
the site is not online yet, but I have put it online for now: http://www.vakantie-rondreizen.nl
December 13, 2021 at 11:33 pm #2048288ElvinStaffCustomer SupportHi there,
You can move the search icon as part of the menu so it doesn’t create a new line.
You can try David’s PHP snippet for this one:
https://generatepress.com/forums/topic/social-icons-6/#post-1650092Here’s how you can add PHP snippets – https://docs.generatepress.com/article/adding-php/
December 13, 2021 at 11:50 pm #2048298ReinoudHi Elvin,
Thank you, I did what you suggested, but now I there are 2 icons, 1 indeed in the right place, but the other ‘third line one’ is still there.
When I turn off the Navigation Search Icon there are 0 icons.
December 14, 2021 at 12:06 am #2048303ElvinStaffCustomer SupportDid you include this part of the code?
add_action( 'wp', function() { remove_action( 'generate_menu_bar_items', 'generate_do_navigation_search_button' ); } );
This one should remove the icon on the menu bar items. If it is included, can you check your site’s php snippets if anything else is adding
generate_do_navigation_search_button
?You can provide us temporary backend access to the site if you need help in checking things out. You can use the forum’s private information text field – https://docs.generatepress.com/article/using-the-premium-support-forum/#private-information
December 14, 2021 at 1:22 am #2048356ReinoudYes,I added this:
add_action( 'wp', function() { remove_action( 'generate_menu_bar_items', 'generate_do_navigation_search_button' ); } ); add_filter( 'wp_nav_menu_items', function( $nav, $args ) { if ( 'enable' !== generate_get_option( 'nav_search' ) ) { return $nav; } if ( isset( $args->theme_location ) && 'primary' === $args->theme_location ) { $search_item = apply_filters( 'generate_navigation_search_menu_item_output', sprintf( '<li class="search-item menu-item-align-right"><a aria-label="%1$s" href="#">%2$s</a></li>', esc_attr__( 'Open Search Bar', 'generatepress' ), generate_get_svg_icon( 'search', true ) ) ); return $nav . $search_item; } return $nav; }, 10, 2 );
December 14, 2021 at 1:48 am #2048378ReinoudI added the login to the private info text field, thx ๐
December 14, 2021 at 2:30 am #2048437DavidStaffCustomer SupportChange:
add_action( 'wp', function() { remove_action( 'generate_menu_bar_items', 'generate_do_navigation_search_button' ); } );
to:
add_action( 'wp', function() { remove_action( 'generate_menu_bar_items', 'generate_do_navigation_search_button' ); }, 500 );
December 14, 2021 at 3:14 am #2048485ReinoudOk, thx, I tried that, but it seems nothing has changed. The code is now like this; hope I did it the right way:
add_action( 'wp', function() { remove_action( 'generate_menu_bar_items', 'generate_do_navigation_search_button', 500 ); } ); add_filter( 'wp_nav_menu_items', function( $nav, $args ) { if ( 'enable' !== generate_get_option( 'nav_search' ) ) { return $nav; } if ( isset( $args->theme_location ) && 'primary' === $args->theme_location ) { $search_item = apply_filters( 'generate_navigation_search_menu_item_output', sprintf( '<li class="search-item menu-item-align-right"><a aria-label="%1$s" href="#">%2$s</a></li>', esc_attr__( 'Open Search Bar', 'generatepress' ), generate_get_svg_icon( 'search', true ) ) ); return $nav . $search_item; } return $nav; }, 10, 2 );
December 14, 2021 at 3:18 am #2048494DavidStaffCustomer SupportOh my i am having one of those days lol.
Change it to:add_action( 'wp', function() { remove_action( 'generate_menu_bar_items', 'generate_do_navigation_search_button' ); }, 500 );
Note: i updated above as well.
December 14, 2021 at 3:21 am #2048497ReinoudThe worked fine David! Thank you and have a good day ๐
December 14, 2021 at 3:22 am #2048498DavidStaffCustomer SupportGlad to hear that!!
-
AuthorPosts
- You must be logged in to reply to this topic.