You are reading the article How To Integrate Google Custom Search Engine To WordPress updated in September 2023 on the website Phuhoabeautyspa.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested October 2023 How To Integrate Google Custom Search Engine To WordPressThe Advantage of adding a Google Custom Search Engine
If you are not aware, the Google Custom Search Engine is a service provided by Google to allow anyone to create a customized search engine. The backend is powered by the Google searchbot, but you are able to customize the search results that appear.Getting Started
In brief, this is what we are going to do.
3. Integrate to your WordPress site1. Create a Google Custom Search Engine (GCSE)
The next step is to customize the look and feel of the GCSE. You can pick from any of the template or customize the default style to your own. Things that you can customize include the font-family, background-color, search input color, search result color, and many other stuff.
Lastly, you will be shown a bunch of code where you need to copy and paste to the place where you want the GCSE to appear. We are going to ignore this for the time being as we are going to add more customization to the custom search engine.2. Customizing the Google Custom Search Engine
Go to the Custom Search Control Panel and select your newly created custom search engine.
There are plenty of things that you can configure here. You can take your time to go through the option one by one. Some of the more important one includes: Autocompletions, Google Analytics, Make money and Look and feel. You can even go into the details and refine the results to appear in the result page
Note: The easiest way is to add the code to your theme where you want it to appear. However, in some cases, the search form might not integrate well with your theme. One alternative that we propose is to modify the search box in your theme, and get it to serve Google search result.
Next, press the “Save and Get Code” button. Copy the code.3. Integrate the Search Result to your WordPress site
Log in to your WordPress dashboard and install (and activate) the plugin “WP Unformatted“.
Next, create a new page. Name the page “Search Result” (or whatever search title you want to show to your reader). In the text editor, go to HTML mode and paste the GCSE code in. Save the page (If you are using WP multisite, you will need to install the Unfiltered MU plugin to allow administrators and editors to insert code in post/page).
Important: Add a new custom field “sponge” (without the quote) and set the value to “1” (without the quote).
Publish the page. Copy the permalink of this search result page.
Next, you have to open up the theme folder and search for the search form code. The default is in the “searchform.php” file, but in case you don’t find the file there, search for it in “header.php“.
The default searchform code should look like this (based on the TwentyEleven theme):action
replacing “your-newly-created-search-result-page-permalink” with the permalink that you have copied earlier.
Next, change the field:
Save the changes to your server.
Your custom search engine should be working now. Perform a search on your site and see the custom search results load up.
Alternatively, if you have chosen the “Two Page” option in the GCSE Look and Feel page, you can use the above method to create a search result page, but add the search form code to the theme file where you want it to appear, probably in the sidebar/widget area.
In addition, you will have to update the GCSE option page with the search result page permalink so the search query can be redirected correctly to the right URL.
Damien Oh started writing tech articles since 2007 and has over 10 years of experience in the tech industry. He is proficient in Windows, Linux, Mac, Android and iOS, and worked as a part time WordPress Developer. He is currently the owner and Editor-in-Chief of Make Tech Easier.
Subscribe to our newsletter!
Our latest tutorials delivered straight to your inbox
Sign up for all newsletters.
You're reading How To Integrate Google Custom Search Engine To WordPress
Update the detailed information about How To Integrate Google Custom Search Engine To WordPress on the Phuhoabeautyspa.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!