Family Encyclopedia >> Electronics

How to add Google search to a WordPress site

Do you want to use Google search on your WordPress site? Although WordPress comes with a built-in search feature, it's not very good. This is why many site owners add Google search to their WordPress site. In this article, we will show you how to easily add Google search to a WordPress site.

How to add Google search to a WordPress site

Why should I use Google search in WordPress?

The default WordPress search feature is not very useful. Often you don't find the relevant results. This forces site owners to look for alternatives.

There are many search plugins for WordPress like SearchWP, Swiftype, etc. The problem is that you still have to manage them and they will impact server resources.

On the other hand, you can use Google's reliable and powerful search feature instead. It's free, allows you to limit the search to just your sites, and can be run from your own site.

Other benefits of using Google search are speed, users already trust the Google brand, and you won't have to maintain or update it.

With that said, let's see how you can easily add Google Site Search to your WordPress site.

To make it easier for you, we've created a video tutorial on how to add Google search which you can watch below.

Subscribe to WPBeginner

However, if you just want to follow the text instructions, you can follow our step-by-step tutorial on how to add Google search to a WordPress site.

Method 1:Add Google Search in WordPress with Plugin

This first method is easier and recommended for beginners. It allows you to add Google search to your WordPress site without modifying your theme files.

The first thing you need to do is install and activate the Google WP Search plugin. For more details, check out our step-by-step guide on how to install a WordPress plugin.

Upon activation, you need to visit Settings »WP Google Search to configure the plugin.

How to add Google search to a WordPress site

The plugin will ask you to provide a Google search engine ID. Here is how you will get a search engine ID.

Visit the Google Custom Search website and click the New Search Engine link on the left.

How to add Google search to a WordPress site

Simply provide the URL of your WordPress site in the 'Sites to Search' field. Next, you need to choose the language of your website. Finally, click the create button to continue.

Google will now create your custom search engine and show you a success message with links to other actions. You must click the button in the control panel to continue editing your search engine.

How to add Google search to a WordPress site

This will take you to your custom search engine control panel. First, you need to click the 'Search Engine ID' button and copy your Search Engine ID.

How to add Google search to a WordPress site

Next, you need to click on the 'Look and Feel' section. Under the design tab, select results only.

How to add Google search to a WordPress site

Once you're done, click the Save button at the bottom of the page to store your changes.

Now you can go back to your WordPress site. Paste the search engine ID you copied earlier into the WP Google Search settings page and then click the Save Changes button to save the plugin settings.

After that you have to visit Appearance »Widgets page. There you will see the WP Google Search widget in the list of available widgets. Drag and drop the widget onto a sidebar where you want to display the search form.

How to add Google search to a WordPress site

Click the Save button to store your widget settings.

You can now visit your website to see the search form in action.

How to add Google search to a WordPress site

Method 2:Manually Add Google Search in WordPress

This method requires making changes to the WordPress theme or child theme files. It is not recommended for beginners. Make sure to backup your WordPress site before making any changes to your theme files.

Visit the Google Custom Search website and click the New Search Engine link on the left.

How to add Google search to a WordPress site

Simply provide the URL of your WordPress site in the 'Sites to Search' field. Next, you need to choose the language of your website. Finally, click the create button to continue.

Google will now create your custom search engine and show you a success message with links to other actions. You must click the Get Code button to continue.

How to add Google search to a WordPress site

On the next screen, you'll see some code in a text area. You need to copy this code.

For this next step, you will need an FTP client. If you need help, check out our guide on how to use FTP to upload WordPress files.

Connect to your website via FTP then go to / wp-content / themes / your-current-theme / binder. Replace your current theme folder with the name of your current theme.

How to add Google search to a WordPress site

Locate the searchform.php file in your WordPress theme directory. Download this file to your computer and open it in a plain text editor like Notepad.

Delete all the contents of the file and paste the Google custom search engine code. Save the file and then upload it back to your WordPress site using FTP.

After pasting the custom Google search code, go to Appearance "Widgets" to drag and drop the search widget to the sidebar.

How to add Google search to a WordPress site

Click the Save button to store your widget settings.

You can now visit your website to see Google search in action on your WordPress site.

Customize the colors and appearance of Google's custom search engine

Go to the Google Custom Search website and edit your search engine. This will display your custom search engine settings. Click on Look and Feel from the sidebar.

Google Custom Search has a few pre-made themes available to choose from. You can also click the customize tab and choose your own font, border, and background colors.

How to add Google search to a WordPress site

Once you're done customizing the look of your search box, simply save your changes. You don't need to paste the code again, these changes will be automatically applied to your search form.

We hope this article has helped you learn how to add Google search to a WordPress site. You may also want to see our list of 19+ Free Google Tools Every WordPress Blogger Should Use.

If you enjoyed this article, please subscribe to our WordPress YouTube Channel video tutorials. You can also find us on Twitter and Facebook.