Site logo

Archived topic

search is own its own line

1 reply · Started by Brian on March 27, 2023

Viewing posts 1–2 of 2

When i enable nav search it goes on to its own line. Should it not be beside the links?

How can put it beside the links?

Thanks

Hi there,

no, the navigation search sits outside the menu, so it will only be inline if there is room for it.

you can move it inside the menu using this PHP Snippet:

add_filter('generate_navigation_search_menu_item_output', function(){
    return sprintf(
        '<span class="menu-bar-item search-item"><a aria-label="%1$s" role="button" href="#">%2$s</a></span>',
        esc_attr__( 'Open Search Bar', 'generatepress' ),
        generate_get_svg_icon( 'search', true ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in function.
    );
});

add_action( 'after_setup_theme', function() {
    remove_action( 'generate_inside_navigation', 'generate_navigation_search' );
    add_action( 'generate_before_header', 'generate_navigation_search' );
});
This archived topic is closed to new replies.