WordPress has an in-built search function for the front end of the site which can be used by the website visitor’s to quickly search through your WordPress site.
But if you have ever tried the default WordPress search, you will notice that it fails miserably compared to other real search engines.
Even though there are a lot of WordPress search enhancement plugins, they barely work perfectly according to your needs and will also put unnecessary load on your web servers.
So in this quick article, let me show you how you can leverage the power of Google by adding Google custom search in WordPress.
Add Google Custom Search
Adding Google custom search is quite easy, first off, head over to the official Google custom search page and click on the link “New search engine.” You may need to login first.
The above action will open the custom search engine creation page. Here enter the domain name in the empty field and click on the “Create” button.
For instance, I have entered my domain name as “www.bloggersignal.com.” This domain name will also be used as your custom search engine name.
Now Google will provide you with three options “Get the code,” “Public URL” and “Control panel.”
Since we are going to add the search engine in our WordPress site, click on the button “Get the code.”
The above action will show you a code snippet which you should add in your WordPress site.
You need to add the displayed code in your theme’s searchform.php file. If you don’t have the file, then create one. Just paste the code you just copied and save it.
Once you are done pasting and saving the file, the regular WordPress search will be replaced with Google custom search.
Go into your WordPress widgets section (Appearance -> Widgets) and add the “search” widget to your site’s sidebar.
That’s it, you are done adding Google custom search in WordPress by replacing the regular WordPress search function.
If you don’t want to meddle with the WordPress files and don’t mind using a plugin, then try using Google Custom Search plugin from WordPress repo.
Hopefully that helps and do comment below leaving your thoughts, experiences and suggestions.