How to replace WordPress Search with Google Custom Search

By | May 16, 2014

WordPress Search functionality needs many improvements but we can’t blame that as its developers are not search engine experts. For complete search results based on everything indexed and served as per the typed keyword, it is recommended to use Google Custom Search. It is a product of search giant so there is no question of its capability and if I say you can monetize your search results, that will be like cherry on top of the cake.

With Google Custom Search implementation and Adsense† sign-up, you can monetize the results as it runs few advertisements from Google Adwords program. And while you’re at optimizing your pages, you might as well take the help of companies like PBNhq to procure some backlinks to enrich your websites.


To replace WordPress default search with Google Custom Search, go to the Custom Search page. Sign in with your Google Account and click on “Add” search engine. Provide the details about your website where you need to embed Google Custom Search.


After that you need to provide an XML file or sitemap to let Google index the pages from your site. It helps Google index pages quickly. You can generate sitemap file using the plugin Google XML Sitemap.

To make money from Custom Search, you need to connect the search engine to Google Adsense account. Click on the “Make Money” tab and connect to your Google Adsense account.

Change the Style and Get the Code


To change the layout and style of Google Custom Search, click on the “Look and Feel” option on left sidebar panel. You can choose between different layouts depending on your requirement and then click on the button “Save and Get Code”. The next page will show you the embed code for this site.


Implement Google Custom Search

To use Google Custom Search instead of default WordPress search, you need to make some changes in the theme’s file.

Create or edit searchform.php file in theme folder – Check if the active theme’s folder is having a file named searchform.php. If yes, edit the file from Appearance ==> Editor window and remove everything from that file. Paste the embed code that you copied from Google Custom Search page. Update the file.

If there is no such file in your theme, create a new file with the same as searchform.php and paste the custom search code in that file. Upload the same to theme’s folder.

Now all the search functionalities will show result in Google Custom Search. To add a new search box in sidebar, drag and drop the “Search” widget in widget ready area from Appearance ==> Widgets window and see how the Google Custom Search works.

WordPress is also having a free plugin named Google Custom Search (link) for those who do not want to edit or create a PHP file.

†Adsense is a CPC (Cost Per Click) based monetization platform. When someone clicks on the advertisements shown along with your site’s search results, you earn money out of that.

Did you find this articles helpful. Share your thoughts through comments below.

Category: Tutorials Tags: ,

About Sanjeev Mishra

I spend most of my time around WordPress and related plugins. It is almost impossible to resist myself from sharing good tips, tutorials and updates related to the platform. After all, I am a blogger by passion.

Leave a Reply

Your email address will not be published.