[Resolved] Navigation Search Icon is placed in new Row

Home Forums Support [Resolved] Navigation Search Icon is placed in new Row

Home Forums Support Navigation Search Icon is placed in new Row

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #2047725
    Reinoud

    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

    #2047975
    David
    Staff
    Customer Support

    Hi there,

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

    #2048280
    Reinoud

    Hi David,

    the site is not online yet, but I have put it online for now: http://www.vakantie-rondreizen.nl

    #2048288
    Elvin
    Staff
    Customer Support

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

    Here’s how you can add PHP snippets – https://docs.generatepress.com/article/adding-php/

    A wise man once said:
    "Have you cleared your cache?"

    #2048298
    Reinoud

    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.

    #2048303
    Elvin
    Staff
    Customer Support

    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

    A wise man once said:
    "Have you cleared your cache?"

    #2048356
    Reinoud

    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 );
    #2048378
    Reinoud

    I added the login to the private info text field, thx 🙂

    #2048437
    David
    Staff
    Customer Support

    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 );
    #2048485
    Reinoud

    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 );
    #2048494
    David
    Staff
    Customer Support

    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.

    #2048497
    Reinoud

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

    #2048498
    David
    Staff
    Customer Support
Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.