Adding Custom Google Search to your WordPress site

Despite being a hugely popular blogging platform, WordPress’s native search function is not much to speak of. While it works pretty well for small sites, the search doesn’t provide the best results for large sites. Although there are plugins such as OpenSearchServer Search and WP-Advanced-Search that improve your site’s search results, you don’t always want to install plugins for everything. For those you wish to simply replicate the functioning of a modern search engine on their site, there is an alternate solution. You can integrate the Custom Search Engine provided by the world’s most powerful search solution, Google. Read on to understand how you can enable Google Custom Search Engine on your site.

Creating a Google Custom Search Engine (CSE)

Signing up for a CSE is as easy as signing up for an email account. Here are the steps required.

    1. Go to Custom Search Engine and sign in using your Google account.

    2. Click Create a custom search engine.

    3. Enter your site’s URL. This URL will also be used as you CSE’s name, by default.

  1. Click CREATE to proceed to the next step.

  2. You will see a notification that you’ve successfully created a CSE. You will also be presented with an option to add it to your site.

  3. Click Get Code. Copy the code and keep it safe for later use.

Adding CSE to your site

Adding the CSE to your site is a two step process-

  1. Adding the code generated in the previous section to the searchform.php file.

  2. Adding the Search widget to an appropriate place (Sidebar or Footer) in the site.

Go to Appearance->Editor from your Admin Dashboard. Open the searchform.php file from within your theme folder, and paste the code into it. In the case of some themes (e.g. twentyfourteen), this file doesn’t exist. But don’t let this stop you. Just create a new file using an editor such as Notepad, and upload it to the theme folder. If the file contains just the CSE code and nothing else, don’t worry about it.

Go to Appearance->Widgets from your Admin Dashboard. Add the Search widget to any of your sidebars.

That’s it. You can see the CSE in action on your site.

Customizing the look and feel

You can customize the look and feel of your CSE from Google’s CSE website.

Go to Google CSE website and edit your search engine. Click Look and feel from the sidebar. It has ready-made themes for search results that you can choose from using the Themes tab. You can also change the border and background colors using the Customize tab. Once you’ve made changes, click Save and the changes will be reflected on your website.

Points to ponder

  • Google’s CSE will use naturally Google results for your site. So you need to ensure that Google has access to all your content. Using a sitemap plugin such as Google XML Sitemap will go a long way in bringing the best search results to your visitors.

  • Sometimes you may end up with duplicate content on your website i.e multiple URLs pointing to the same content. For example,

When there are multiple pieces of identical content on the Internet, it is difficult for search engines to decide which version is more relevant to a given search query. When duplicate content is present, site rankings dip, and search engines provide less relevant results. To solve this problem, it is good to have an SEO plugin such as All in One SEO Pack installed on your site.


Google CSE is a good tool to enhance your site’s search results. Besides, you can also use AdSense to monetize your search results. Hope this tutorial helped you implement CSE on your website.


Would love your thoughts, please comment.x