When you have to search something on the web, you will probably use Google search engine to find what you need. So, why not use the power of Google to search content exclusively on your WordPress website? Google Custom Search is here to help.
In case you have missed it, you should see some of the best WordPress search plugins which can proudly replace the standard WP search and make your website even better place for a random visitor. Among other, we mentioned Google Custom Search which can be implemented in any website and if you are working with WordPress, stuff gets even easier when you ask a plugin for help.
To create your own search engine, you will only need a Google account. In this tutorial, the rest will be done by WP Search Plugin.
- Go to Google Custom Search website (https://cse.google.com/cse/)
- Choose “New search engine”
- Find “Sites to search” section where you need to write pages which will be included in the search engine you are creating. You a free to add not only your own website but any URL you want to be found in the search results.
- Select language you want to use for your search engine
- Click on “Create” button
- Get the code by copying it into your clipboard
You can customize the look and feel of your newly created Google search engine. Make it look whatever you like and play with the options as long as you want to.
Now let’s place that search engine into WordPress and allow people to actually use it:
- Go to Plugins->Add New
- Find “WP Google Search” plugin, install it and activate
- Navigate to Settings-> WP Google Search where few options will displayed in front of you:
- Save changes
- Navigate to Appearance->Widgets
- Find “WP Google Search” widget and drag it on the sidebar or wherever you want it to be
- Open your website and enjoy searching your own content with Google Custom Search
– Google Search Engine ID: After registration process, you will get ID which looks like this: 012345678901234567890:0ijk_a1bcde. Write your ID in the box
– Display search box before search results: If you check this option, a search field will appear above search results and make the process even more similar to Google itself
– Support Overlay Display: You need to check this option only if you have checked the same one in Google Custom Search admin options. If so, new search results won’t be opened in the new page but will overwrite the previous ones.
– Use default corrections CSS: By default, this option is checked. Leave it so if you want the plugin to take care of some parts of the CSE look.
– Search Page Target URL: You can’t change anything here but only see the URL the plugin has created to work properly. Do not change or delete the page if you want your Google Custom Search to work properly
If you want to place your newly created Google searchbox somewhere else in your theme besides the widgets area, you will only need the [wp_google_searchbox] shortcode. So, for example, you can place the searchbox in the header of your theme with the following piece of code:
<?php echo do_shortcode( '[wp_google_searchbox]' ); ?>
If you want to learn more tricks about customizing search results in WordPress, check out our other articles on this topic.