Site logo

Archived topic

Navigation Search Icon is placed in new Row

12 replies · Started by Reinoud on December 13, 2021

Viewing posts 1–13 of 13

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

Hi there,

can you share a link to your site where i can see the issue ?

Hi 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.

Did 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

Yes,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 );

I added the login to the private info text field, thx :)

Change:

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 );

Ok, 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 );

Oh 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.

The worked fine David! Thank you and have a good day ;)

Glad to hear that!!

This archived topic is closed to new replies.