How to Get Google Search for WordPress by Replacing Default Search

Last Updated on February 10, 2023 by 39 Comments

Editorial Note: We may earn a commission when you visit links on our website.
How to Get Google Search for WordPress by Replacing Default Search
Blog / Tips & Tricks / How to Get Google Search for WordPress by Replacing Default Search

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.

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 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 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:

  1. Log into Google Custom Search Engine.
  2. Click New Search Engine and enter the details:
    • Sites to searchYou 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 types, such as Product or Event.
  3. 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:

  1. Add Google CSE code to your website manually.
  2. 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:

Custom Search Engine Created

Click the Get Code button, and copy the code in the box on the following page:
Google CSE Code

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:
Edit searchform.php

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:

Add search widget to the 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)

WP Google Search plugin

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:

Google CSE ID

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)

Custom Google Search plugin

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.


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 /


Want To Build Better WordPress Websites? Start Here! 👇

Take the first step towards a better website.

Get Started
Premade Layouts

Check Out These Related Posts

Splice Video Editor: An Overview and Review

Splice Video Editor: An Overview and Review

Updated on March 10, 2023 in Tips & Tricks

Video is a valuable form of content for social media. Unfortunately, creating quality videos is usually a long process that involves moving mobile footage to a desktop app for editing. However, mobile editing is on the rise. Apps such as Splice Video Editor make it possible to efficiently create...

View Full Post
How to Use Font Awesome On Your WordPress Website

How to Use Font Awesome On Your WordPress Website

Updated on September 16, 2022 in Tips & Tricks

When given the choice between using a vector icon or a static image, it’s a good idea to go with the vector. They’re small and fast to load, and they can scale to any size without a loss of resolution. Font Awesome is a superb library of vector icons that you can use on your websites,...

View Full Post


  1. 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. 🙂

  2. Thank you for sharing this information.

    • Thank you!

  3. Thanks for the awesome tutorial Tom!
    It is so easy to do it. Will change the default WordPress search with Google’s custom search.


    • Thanks, Tauseef!

  4. 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!

  5. Such an Amazing way to do it.
    Thanks Tom!

    • Thanks, Mahum!

  6. 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!

  7. This is a great tutorial. Now I can easily replace default search with Google custom search. Thanks for the awesome share.

    • You’re welcome!

  8. I was thinking to do this for a long time.
    Thanks Tom!

    • Thanks, Ankush!

  9. 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!

  10. 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?

  11. 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!

  12. A Fabulous Post! Shareing…

  13. Hi, I’ve managed to get it to work by adding the html code to a sidebar widget!

    • What was the code?

  14. 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.



            • 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. 🙂

  15. 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)?

      • 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.

  16. Best article for custom Google search add in WordPress. Great job Tom.

  17. 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! 😉

  18. How can this be done using Divi?

  19. 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!

Leave A Reply

Comments are reviewed and must adhere to our comments policy.

Get Started With Divi