Archived topic
Using Google Search via a Search Page
3 replies · Started by Nates on March 13, 2020
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
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.
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.
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 );