As you may have discovered, in spite of its phenomenal performance as a blogging platform/CMS, WordPress falls woefully short in the search department. There are other plugins available that will improve your search results, like Amazon CloudSearch in WordPress with Lift or SearchWP. But for those of you who don’t want to install 15 of them to just barely imitate the functionality of modern search engines, there is another option: replace WordPress search with Google custom search. In this tutorial, we will to show you how to add Google Custom Search in WordPress.
If you don’t like the video or need more instructions, then continue reading.
Create a Google Custom Search Engine for your WordPress Site
Go to Google Custom Search Engine and sign in using a Google account. Once there, click on New Search Engine and provide your WordPress website’s URL. The URL will also be used as your search engine’s name in your Google Custom Search Engine dashboard. Click on Create button to proceed to the next step.
On the next page, you will see a notification that you have successfully created your custom search engine. You will be presented with an option to add it to your site or get the public URL. To add this custom search engine in your WordPress site click on the Get Code button.
On the next page you will get the code for your custom search engine. Copy the code you will need it in the next step.
Adding Google Custom Search in WordPress
Go to Appearance » Editor in your WordPress admin area and click on
searchform.php file to open it in the editor. Paste the custom search engine code in the file. It is alright if this file does not contain anything else and just the Google custom search engine code.
If your theme does not have a
searchform.php file, then you need to create one using a text editor like Notepad and upload it to your theme directory using FTP client.
After pasting Google custom search code, go to Appearance » Widgets to drag and drop the search widget into your sidebar.
That’s all, preview your site to see it in action.
Customizing Google Custom Search Engine Colors and Looks
Go to Google Custom Search website and edit your search engine. This will show settings for your custom search engine. Click on Look and Feel from sidebar. Google custom search has some premade themes available to choose from. You can also click on customize tab and choose your own font, border, background colors. Once you are done customizing the looks of search box, simply save and your changes will appear on your site.