BACK TO TOP

How to Add Google Search to Your WordPress Website

How to Add Google Search to Your WordPress Website

Whatever kind of content you are hosting on your website, you want to make it as easy as possible for your visitors to get around. It’s difficult enough getting people to visit your website at all, but that’s only the first step: you need to make them happy and keep them coming for more, and easy navigation to their desired content goes a long way towards improving user experience. You could add a search bar to your WordPress menu, or you could allow your visitors to filter your content by category or tag, but there is yet another way to help your visitors reach the content they want: you could add Google search to your website. And that is what this tutorial is all about.

But WordPress comes with its own search functionality: do I really need a Google search? we hear you ask. The why is exactly the question we would like to address before we get down to the nuts and bolts of the how-to.

Qode Themes: Top Picks
Bridge New Banner
Bridge

Creative Multi-Purpose WordPress Theme

Stockholm WordPress Theme
Stockholm

A Genuinely Multi-Concept Theme

Startit WordPress Theme
Startit

Fresh Startup Business Theme

Why Do I Want Google Search on My WordPress Website?

It’s easy enough to answer that: harnessing the power of Google has its benefits, and WordPress’s default search function has its drawbacks.

WordPress’s default themes have a search function which works, but it is pretty basic. It will return results based on keywords, and that’s really it. If you want a more versatile search feature, you ought to look elsewhere.

Adding a custom search bar, either as a theme’s feature or as a plugin, often works better and provides you with more options. Plugins, and themes as well, require keeping up with WordPress updates, though. Google, for better or for worse, does not. Also, each search which uses your server’s resources (such as one using a theme’s search feature or a search plugin) may cause slow running – not great UX, in other words, if your server is dealing with more traffic than it can handle.

Google, on the other hand, is fast, and, with a Google search functionality, you could also limit Google’s searches to your own website or websites. Additionally, Google searches are free for the end user, and setting them up on your WordPress website is free as well. Finally, the world’s most popular search engine allows your users to take advantage of Google operators and refine their searches.

Simply put, Google is faster and more versatile than WordPress’s search function, and it also brings the Google brand into play, advertising to your visitors the efficiency and speed which are associated with the brand and which had contributed to making Google the search engine powerhouse it is today.

With that in mind, let’s get right down to the brass tacks. There are two ways to go about adding Google search to your WordPress website: with a plugin, or by changing your theme files. In either case, you need to create a custom search engine using Google’s Programmable Search Engine service.

Here is what we will be discussing:

How to Create a Custom Google Search Engine

The first thing you need to do is register on Google’s Programmable Search Engine website. This service will allow you to create and configure a custom, automatically updated search engine powered by Google, which we will show you how to add to your website.

Once on the website, click Get Started.

Get Started

You will be taken to the screen where you need to configure your new search engine.

The most important settings are the Sites to search fields. You can set your search engine to search a single website, as we have, but also multiple websites, individual pages, parts of a website, or entire domains.

You also need to set up the language, the default being English, and you need to Name your search engine.

Having done all that, you can CREATE your custom search engine.

Create Button

You will be taken to a screen with buttons which will allow you to Add it to your site, View it on the web, and Modify your search engine.

Created

What you do next depends on the method you wish to use to add Google search to your website. In either case, keep this tab open. You will need it for later.

How to Add Google Search to Your WordPress Website Using a Plugin

If you want to use a plugin to add the custom search you have created, you must first install the plugin. We will be using WP Google Search. Once you have installed it, you will need to configure it to use your custom search engine. To navigate to the plugin configuration screen, select Settings>WP Google Search from your WordPress dashboard.

Settings WP Google Search

You will need to enter your Google Search Engine ID into the top field. To find out what it is, go to your programmable search engine page and click the Control Panel button.

Control Panel

You will find the Search engine ID in the Basics tab of the search engine’s control panel. Copy this ID code by clicking the Copy to clipboard button.

Copy to Clipboard

Going back to your plugin configuration screen, paste the ID in the Google Search Engine ID field and click Save Changes.

Paste ID
Save Changes

Now, to introduce this custom search engine to your plugin, you need to add its widget to a widget area. To do that, navigate to the widget selection screen by selecting Appearance>Widgets from your WordPress dashboard.

Appearance Widgets

Next, you need to find the WP Google Search widget in the left-hand side section of the screen. We have chosen to add our Search to our Header Bottom Right area. Note that the availability of widget areas and their behaviour will depend on the theme you are using. We are using our flagship Bridge theme, wherein the Header Bottom Right area is right next to the top menu.

To add the widget to a widget area, you can drag-and-drop it from the left-hand section of the screen to a widget area on the right, or you can do as we did: select a widget area from the widget’s drop-down menu and click Add Widget.

Add Widget

And your widget will appear in your chosen widget area.

Search Widget

How to Add Google Search to Your WordPress Website Using Code

You can also choose to go a different route: modifying your code. Find the Get code button on your Programmable Search Engine screen and click on it.

Get Code

You will see some code you need to copy in order to integrate your custom search engine into your website.

Copy Code

You then need to copy this code into your theme’s searchform.php file. You can find it by navigating to Appearance>Theme Editor.

Theme Editor

Select searchform.php from the right-hand side menu, and replace all the code in it with the code you copied from your Programmable Search Engine. If you want to be extra careful, back up your searchform.php file. In fact, back it up even if you want to be just plain careful. Once you have replaced your code, click Update File.

Searchformphp

You still need to add a search widget to your website. Navigate to Appearance>Widgets and add the Search widget to your preferred widget area. We will again add it to our Header Bottom Right area.

Add Widget

And your Google-powered search form will appear where you put it.

Search Widget

Your visitors can now search for anything, and get only the results from your website, or whichever corner of the internet you‘ve configured your search engine to look into.

Search Preview

In Conclusion

As we have shown, setting up Google search on your website is easy and free, whether you do it by making changes to your theme’s code, or by installing a plugin. In either case, you can’t go wrong, just be careful to back everything up if you are going to modify your code. Whether you are dissatisfied with WordPress’s search option, if you can’t find a plugin which works for you, or if you simply want to create a better way for your users to access your content, Google might be the way to go.

Post your comment

Comments0