[Support request] Using Google Search via a Search Page

Home Forums Support [Support request] Using Google Search via a Search Page

Home Forums Support Using Google Search via a Search Page

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1194331
    Nates

    I would like to use Google Custom Search as follows

    1. User clicks on the Search Icon (instead of opening a search bar it takes them to a search page)
    2. Then it displays the page for the Google Search Feature

    Currently, I followed a thread of using it via the Search Icon displaying a search bar, but this way loads alot of JS and CSS

    #1194582
    David
    Staff
    Customer Support

    Hi there,

    maybe a plugin like this for creating the Google Search page:

    https://en-gb.wordpress.org/plugins/wp-google-search/

    Then you could create a Menu item in your navigation to link the search page.

    #1194842
    Nates

    If I make the menu item, it is not visible like the icon, the user then has to go through 2 steps to get to the search page, hence would be nice to have the icon configurable to be a search page url.

    #1195036
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    You could deactivate our Navigation Search, then do this to add a menu item with the SVG to your menu:

    add_filter( 'wp_nav_menu_items', function( $items, $args ) {
        if ( isset( $args->theme_location ) && 'primary' === $args->theme_location ) {
            return sprintf(
                '%1$s<li class="open-search-page"><a aria-label="%2$s" href="URL TO YOUR SEARCH PAGE HERE">%3$s</a></li>',
                $items,
                esc_attr__( 'Open Search', 'generatepress' ),
                generate_get_svg_icon( 'search', true )
            );
        }
    
        return $items;
    }, 10, 2 );
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.