Horje
How to Add Google Search to a WordPress Site?

Adding Google Search to a WordPress site can enhance SEO ranking and improve the overall user experience. Google offers a framework, Google Programmable Search Engine, which simplifies the process of integrating a search bar into a WordPress site.

Note: It is not feasible to add Google search in a WordPress site without using plugin.

Steps to Add Google Search to a WordPress Site

Step 1: Open Programmable Search Engine

The first step is to go to the website of the Google programmable search engine, go Google and type programmable search engine, and open the website, google gives a code-specific csx ID that can be copied and used on any website to add the search engine to the page.

002_programmable-search-engine

Open Programmable Search Engine.

Step 2: Enter Website Details

Enter the details for your website:

  • Name: Provide a name for your search engine.
  • Sites to Search: Enter the specific site URLs you want the search engine to index.
  • Click on “Create”.
004_enter-the-details

Enter Website Details.

Step 3: Create the Custom Search Engine

After creating the search engine, configure additional settings:

  • Image Search: Enable if you want to include images in search results.
  • SafeSearch: Enable to filter out adult content.

Complete the CAPTCHA and click on “Create”.

005_click-on-create-button

Create the Custom Search Engine.

Step 4: Copy Search Engine Code

Once the create button is clicked, it will redirect to a new page where it will say that the search engine is created now simply copy the code by clicking on the copy button and paste it by following further steps.

006_csx-id-copy

Copy CSX ID.

Step 5: Open WordPress Dashboard & Add Plugin

For pasting the code we will have to install a plugin that can easily paste the code inside the body tag of the website, for this first visit the admin panel of the website by visiting the following URL (replace yourwebsitename.com with the name and domain extension of your website.)

https://yourwebsitename.com/wp-admin

After this, click on the plugins tab from the left side and select the “Add new plugin” option, as seen in the image below:

007_click-on-add-new-plugin

Open WordPress Dashboard & Add Plugin.

Step 6: Install WPCode Plugin

Once the above steps are completed, a search button is shown in the middle right corner of the window, from here search for a plugin called “WPCode” which can help to create and insert code snippets inside the WordPress body tag.

Click on the Install Now button to install the WPCode plugin on the website.

008_install-wpcode-(1)

Install the WPCode Plugin.

Step 7: Click on Add Snippets

Once the plugin is installed, a new option called Add Snippets will appear inside the plugins tab on the lower left side, click on that Add Snippets button and move to the next step.

009_click-on-add-snippet

Click on Add Snippets.

Step 8: Click on Add Custom Snippets

After the above steps, there will be several different options available, click on the first option that says add your custom code, this will allow you to add custom code and it will be automatically pasted in the body of every page in the WordPress, as you can see in the image below:

010_click-on-add-custom-snippet

Click on Add Custom Snippets.

Step 9: Paste Custom Search Code

Once the snippet is opened, it will ask for only two details, first is the name of the code snippet and the code that needs to be pasted, in the name anything can be written such as Google search, etc. and in the code preview the code needs to be pasted which was copied previously from the google’s programmable custom search engine.

011_code-preview

Paste Custom Search Code.

Step 10: Test the Search Engine

Once all of the steps are completed successfully, reload the website and a Google search engine will appear on the site, it will look similar to the one below:

012_custom-search

Test the Search Engine.

Type any query related to the website such are the website name, article name, etc. and it will run a Google search within the website as seen in the image below:

013_gfg-search

Test the Search Engine.

Conclusion

Google search can be implemented in the WordPress site easily as Google offers a tool called Google Programmable Custom search which helps to create a custom ode and add the code inside any WordPress site using either the manual process of adding the code inside the body of the code or simply use a plugin which can paste the code in the body tag of the WordPress site.




Reffered: https://www.geeksforgeeks.org


Web Technologies

Related
How to install WordPress with Ubuntu 20.04 and a LAMP Stack? How to install WordPress with Ubuntu 20.04 and a LAMP Stack?
What type of Hashing does WordPress use? What type of Hashing does WordPress use?
Tabbed Image Gallery in WordPress Tabbed Image Gallery in WordPress
How to Fix Error EJS 'partial is not defined'? How to Fix Error EJS 'partial is not defined'?
How to Enable mod_rewrite for Apache 2.2? How to Enable mod_rewrite for Apache 2.2?

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
17