The default WordPress search may be fine when you are just starting out, but as your site grows you will start to see some limitations. Notably, as the amount of content on your site increases, you will realize that it doesnโt always show the most relevant results โ making your content harder to find for your visitors.
Google is most famous for search, and using Google Search on your site can provide a much better experience for your users. If they can find what theyโre looking for, it becomes much easier to keep them on your site.
This article will look at why you should consider switching from the default WordPress search to using Google Search on your site, then step you through how to make the switch.
- 1 Why You Should Switch to Using Google Search for WordPress on Your Site
- 2 How to Set Up Your Google Custom Search Engine
- 3 How to Add Your Google Custom Search Engine to Your WordPress Website Manually
- 4 How to Add Your Google Custom Search Engine With a Plugin
- 5 How to Customize Your Google Custom Search Engine
- 6 Conclusion
Why You Should Switch to Using Google Search for WordPress on Your Site
Though improvements have been made to the default WordPress search in recent years, it still works by querying the WordPress database, looking for keyword matches in posts and pages. The basic search has some limitations that affects usability:
- Results are often chronological (although some attempt has been made to weigh relevance).
- Comments, custom post types, and other data are not included without the use of a specialized plugin, such as SearchWP.
- The search results cannot be refined through advanced parameters.
- The search results display the default WordPress excerpts (often the first paragraph).
Many of the limitations can be addressed with plugins, and in a previous post weย looked at the best WordPress search plugins available.
Google, on the other hand, is the standard in internet search. We use the word as a verb (โjust google it!โ) to show how they have captured the concept of search. So if you or your users have started to become frustrated by the results of the WordPress search on your site, you can take advantage of Googleโs search expertise.
Replacing the default WordPress search with Google search can help by:
- Including more relevant search results through the power of Googleโs indexing and ranking.
- Including all content on your website within search results.
- Searching across multiple domains to provide results from your other web properties.
As the website owner, Google search also enables you to monetize your search results by integrating AdSense, and driving traffic to your other web properties included in the search.
Even the WordPress.org website uses Google search, so it can definitely handle your website.
Letโs see how easy it is to get started!
How to Set Up Your Google Custom Search Engine
Google knows they have great search, so they provide Google Custom Search to make it easy for websites to add a search box to their site that uses Googleโsย technology. The basic tool is free, but if you want to go further into customizing the design (like removing ads or the Google branding), or to add more powerful features (like rich snippets and data biasing), you can look at Google Site Searchย (which starts at $100 per year).
Creating a Custom Search Engine for your website is very simple:
- Log intoย Google Custom Search Engine.
- Click New Search Engine and enter the details:
- Sites to search:ย You can enter one or more URLs for the sites or pages you want to search, on your site or any other.
- Language:ย This is the language of the search engine itself, so it affects buttons and design elements.
- Name:ย This is auto-generated from the URLs entered above, but you can change it.
- Advanced options:ย You can additionally restrict the search to only pages that include certain Schema.org types, such as Product or Event.
- Click Create.
Your Custom Search Engine is now ready! The next page will enable you to add it to your website, view it online, or modify it through the control panel. You can add the Custom Search Engine (CSE) to your website in two ways:
- Add Google CSE code to your website manually.
- Use Google CSE ID with a plugin.
Weโll cover both of those options below, before looking at ways you can customize the search engine.
How to Add Your Google Custom Search Engine to Your WordPress Website Manually
You can add the Google CSE to your website manually. This is the fastest way, and may be preferred for those of you who donโt wantย to add yet another plugin to your site. If all you want to do is completely replace the default WordPress search form with the Google CSE, the manual approach gets that done with no fuss.
When you successfully create your CSE, you are given an option to add it to your site:
Click the Get Code button, and copy the code in the box on the following page:
Once youโve done that, go to Appearance > Editor in the WordPress admin, then click on searchform.php in the list on the right to open it in the editor:
Once thatโs done, paste the Google CSE code into this file. You can replace the contents of the file completely, and once youโre done, click Update File.
This is pretty straightforward, but there are a few things to look out for:
- In general, you should really create a child theme for your theme rather than editing the code of the included files. Weโve covered why you should use a child theme and how to create one before.
- If your theme doesnโt have a searchform.php file, you can create one using a text editor and upload it to your theme directory.
- If you want to include the search form somewhere new in your sidebar, you can go to Appearance > Widgets to drag the search widget into a sidebar:
If youโre not comfortable adding the code yourself, you can choose to use a plugin instead. Letโs see how that works!
How to Add Your Google Custom Search Engine With a Plugin
There are a couple of plugins you can use to add Googleโs CSE to your site:
1.ย WP Google Search (Free)
If you are on a budget and want a free plugin to help you add Google CSE to your site, you canโt go wrong with WP Google Search. This plugin has over 6,000 active installs and a 4.5 star satisfaction rating.
To use this plugin, copy your Google CSE ID by going to the Setup page in the CSE dashboard:
Paste that ID into the pluginโs settings and youโre ready to go!
The plugin has limited settings, but you can customize the search within the CSE dashboard, as weโll discuss shortly.
2.ย Custom Google Search ($49 per Month, as Part of a WPMU DEV Subscription)
A paid option for working with the Google CSE is WPMU DEVโs Custom Google Search. As with their other plugins, it is available as part of their monthly membership ($49 per month) which includes all their plugins and themes.
This plugin requires you to copy the Google CSE code (not the ID) into its settings. We showed you earlier how to get that code. Once you have entered the code, you can select and customize:
- How the search results are displayed.
- A color style for the search elements.
- Whether to show the search button.
- Whether a sidebar is displayed on the search page.
- A theme for the search popup.
So without going back to the Google CSE dashboard, you can customize the look and feel of your website search using this plugin.
If you want to do more advanced customization of your CSE, take a look at the next section to see the options that Google provides.
How to Customize Your Google Custom Search Engine
If you want to really get creative with your CSE, Google provides a wide range of options to help you customize.
Customize the Look and Feel
- Layout:ย You can select from multiple layouts for your search engine, including overlay, compact, and results only. Choose the one that best suits your website.
- Themes:ย You can choose a design theme for your search engine, such as minimalist.
- Customize:ย This tab lets you select the font, border, and background for various search engine elements, such as URLs and buttons.
- Thumbnails:ย You can enable or disable thumbnail images in your search results.
Add Search Features
- Promotions:ย You can add specific URLs (even external ones) to be promoted whenever users search your site for specified keywords.
- Refinements:ย You can enable your users to filter the search results using predefined categories or labels.
- Autocomplete:ย Google can generate autocompletion terms for you to help users search your site more quickly.
- Synonyms:ย Help your users by adding synonyms to your search engine, so that related terms are searched simultaneously.
A useful feature is the integration with Google Analytics, which will enable you to get detailed statistics and data on how your users are searching your site.
Conclusion
You put a lot of time into creating content on your site, but if it cannot be found by users searching your site, they will likely leave. Using Google Search in your WordPress website can help your users find articles of interestย your site more quickly and easily, and help you better utilize your siteโs content.
Weโve shown you why you should switch, andย also given you step-by-step instructions to switch from the default WordPress search, so thereโs nothing stopping you from getting this done today.
Are youย using Google Search in your WordPress website? We would love to hear your tips and tricks. Share your experiences and subscribe to the comments section below!
Article thumbnail image by PureSolution / shutterstock.com
Thanks i am looking for These plugins. Which Plugin Can you suggest? Or we will test one by one.
Sadri, you should test each one โ only you can decide which one is more suitable to your needs. ๐
Thank you for sharing this information.
Thank you!
Thanks for the awesome tutorial Tom!
It is so easy to do it. Will change the default WordPress search with Google’s custom search.
Regards
Tauseef
Thanks, Tauseef!
Very cool tutorial, Tom. Like Geno said, I am completely blind to this side of search functionality and look forward to implementing this into some sites with stacks of posts and categories.
Youโre welcome, Jeremy!
Such an Amazing way to do it.
Thanks Tom!
Thanks, Mahum!
Hey Tom, Thank you For Sharing This Amazing Article/Tutorial.
I Just Followed All your Step And Got It Done ๐
No problem, Sarah โ glad you enjoyed it!
This is a great tutorial. Now I can easily replace default search with Google custom search. Thanks for the awesome share.
Youโre welcome!
I was thinking to do this for a long time.
Thanks Tom!
Thanks, Ankush!
Good hack to replace default search with Google search. Why not we can have one option in epanel to enable this feature just like that.
Iโm sure someone resourceful enough can do it! It would be a handy addition!
I’ve on and off with regard to Google Search on my sites. It is perhaps too good in the sense that it yields too many results. The most troublesome issue is that it indexes the sidebar. My sidebar is filled with important tags and categories and more. I have not found a way to exclude the sidebar from the results list. Anyone?
Does Divi use the default search? My Website seems to search custom posts, but if it does use the default search I would want to change it, so…
Thanks for your comment! Divi does use the default search โ hope that helps!
A Fabulous Post! Shareingโฆ
Hi, I’ve managed to get it to work by adding the html code to a sidebar widget!
Richard
What was the code?
Great post – but I can’t seem to get it to work in the Divi theme using the WP Google Search plugin!? I pasted the ID and did what you outlined. Any ideas?
I second this issue! I too having problems in getting the WP Google Search plugin to display in Divi. I do not wish to build a sidebar widget in order to make this work. Any tips Tom?
Hello both โ Iโm a little unsure whatโs happening here. Are you seeing a search box that’s not doing what you expect, or something else entirely?
It appears not to be compatible with the Divi theme. The default Divi search overrides the plugin thus displaying the basic search results.
Widget method:
I removed the basic Search widget and placed in WP Google Search widget and I get nothing. Then I placed the default widget below the WP Google Search widget and only the default works.
Divi has it’s own Search button that can be placed in your menu bar at the top of the screen.
Customizing โธ Header & Navigation
Header Elements > SHOW SEARCH ICON…
You can turn this on and off but you get the same effect as using the sidebar widget method.
I’m stumped.
Hi Jack,
Sorry you’re experiencing that issue. I’d recommend creating a ticket in our support forum to make sure they don’t have a fix for that. If not it will be good to have a record of it for our developers going forward.
Thanks!
Nathan
According to Richard Duszcaak, some code has to be added to get it to work. I created a ticket but the person on the other end was clueless and asked me silly questions. This has gone way over my experience level and time constraints. I’m not a developer, I’m just a businessman trying to quickly build a large website within budget restrictions. I’ve since deleted the plug. I’m sticking with the default WP search. Thanks for your team’s effort in this issue. ๐
I think I’d prefer to refine the existing search. Google is a good start point but it’s trying to be all things to all men (or women). I’d say it’s a given that you know more about your audience and their interests than Google does, after all they are catering to every possible need.
Is it possible to add additional weighting to the search or offer results for specific types of content (pages/documents)?
I’m not sure I understand your rationale Andy, but each to their own ๐
If you want Google Search, as far as I’m aware, Google Search is what you get (i.e. no ability to fiddle with their algorithms). There are options to fiddle with WordPress search though, with plugins like Relevanssi. You might find this useful: https://www.elegantthemes.com/blog/resources/upgrade-your-site-with-the-best-search-plugins-for-wordpress/.
Thanks Tom, in my previous job people would say to me “can it be like Google or Dropbox” or whoever produced the current market leader. As the lead on innovation I would always take that request and use the market leaders as a start point and then overlay the knowledge of my client base and produce a system like Google or Dropbox but tailored specifically to my audience. At the time I was developing an extranet for the UK military so had the advantage of knowing my audience and their specific requirements. For example 2 documents with similar titles, the older document is more relevant based on my search terms but I want to ensure that the more recent document is top of the list so I weight it heavily towards the date published. I’d always seek to improve on what people see as the ‘Standard’ because I know my target audience and why they are on my site.
Best article for custom Google search add in WordPress. Great job Tom.
Very timely post. I have been a bit disappointed in the default WP search and just enabled Google search with the help of @genoq. I’m convinced that it had become necessary as I continued to add more content. I’m nearing 1,100 posts alone.
1,100 posts? Sounds necessary to me Phil! ๐
How can this be done using Divi?
Great stuff Tom. My buddy and fellow Divi enthusiast Phil Simon was just asking me how the search was listing and organizing results and I had no clue other than we figured out it was sorting by date.
Yeah…WordPress search has a long way to go in terms of matching Google’s functionality!