How to Add Google Custom Search (Programmable Search) to WordPress

WordPress’s built-in search is basic: it often ranks results by date rather than relevance, does not correct spelling, and struggles on large sites. Google’s free Programmable Search Engine (formerly Google Custom Search) gives your readers Google-quality results from your own site, and you can earn money from search ads by connecting AdSense.

Here is how to add it to WordPress in 2026, step by step.

Step 1: Create a Programmable Search Engine

  1. Go to programmablesearchengine.google.com and sign in with your Google account.
  2. Click Add (or Get started).
  3. Name your search engine, for example your blog name.
  4. Under What to search, choose Search specific sites or pages and enter your domain, such as yourblog.com/*.
  5. Complete the check and click Create.

Step 2: Choose How Results Appear

Open your search engine, go to Look and feel, and pick a layout. For a blog, Results only is the cleanest: you place a search box in your sidebar or header, and results appear on a dedicated search page on your site, so visitors never leave. Adjust colors to match your theme and save.

Step 3: Connect AdSense to Earn From Searches (Optional)

In the control panel, open the monetization or AdSense section and link your AdSense account. Search ads then appear above your results, and you earn when visitors click them. You need an approved AdSense account; see how to get AdSense approval.

Step 4: Create a Search Results Page in WordPress

  1. In WordPress, go to Pages > Add New Page and title it “Search Results” (the URL will be something like yourblog.com/search-results/).
  2. In the Programmable Search control panel, open Overview and copy the code, or the results element code if you chose Results only.
  3. Add a Custom HTML block to your page and paste the code.
  4. Publish the page.

Use a slug like search-results rather than /search/, because /search/ is reserved by WordPress for its own search.

Step 5: Add the Search Box to Your Site

In the control panel, set the results page URL to your new page, then copy the search box code. Add it where you want the box to appear:

  • Block themes: go to Appearance > Editor, open your header or sidebar template, and add a Custom HTML block with the code.
  • Classic themes: go to Appearance > Widgets and add a Custom HTML widget to your sidebar.

Remove WordPress’s default Search block or widget so visitors do not see two search boxes. Test a search to make sure results load on your page.

Is Google Search Better Than WordPress Search?

  • Pros: relevant results, spelling suggestions, fast, free, and optional ad revenue.
  • Cons: only shows pages Google has indexed, new posts can take time to appear, the free version shows Google ads, and styling is limited.

Alternatives include search plugins such as Relevanssi or SearchWP that improve WordPress’s own search without relying on Google.

Frequently Asked Questions

Is Google Custom Search still available?

Yes, under the name Programmable Search Engine. It is free with ads, and you can connect AdSense to earn from those ads.

Can I remove ads from Google search results on my site?

Free search engines show ads. You can earn from them by linking AdSense.

Why are my newest posts missing from search results?

Programmable Search uses Google’s index, so new posts appear only after Google indexes them.

Comments

16 responses to “How to Add Google Custom Search (Programmable Search) to WordPress”

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Gina Davis Avatar
    Gina Davis

    Hey thanks. I appreciate the simplicity of your tutorial.

    I was wondering, I know you can get penalized for clicking on ads. Can you get penalized for using the Google adsense search on your website? In past to find old blogs and share their links I would just go to my website.

    thx

    1. Istiak Rayhan Avatar
      Istiak Rayhan

      You won’t penalize as you are not clicking your own ads.

  2. Ayan Avatar
    Ayan

    Thanks for the live-saving post but I think the option of “on a Google page in a new window” is better than “on my website using an iframe” under “search results”. I feel it because of the two reasons:
    1. The first one is, you do not need to create a special page for the search results in the former option.
    2. Secondly, it also ensures that the content of the sidebar do not disturb the search results. As in the latter option, the sidebar ads were overlapping the Google custom ads in my website. So, I prefer the former one.

  3. harshi Avatar
    harshi

    what if i want to apply this custom search to my default search of the theme in the header !

    please help!

  4. Wilma Yulia Avatar
    Wilma Yulia

    Hi Istiak!
    I’m using responsive theme with small content width (<<800px, google need min 795px), so I made a page (search result page) and upload it to root folder.. :(
    Do you have better idea?
    Thanks for this tutorial. It's easy to understand.

  5. Kiron Avatar
    Kiron

    Brother how to add search box in my blogspot blog?

  6. rahul pahal Avatar
    rahul pahal

    Obviously, who doesn’t want to earn a few more bugs. If one has started earning from adsense, he should also use google custom search for more revenue. And even google custom search is more attractive than the normal wordpress search boxes.

  7. Martin Cid Avatar
    Martin Cid

    Good article, Istiak. It’s helping me a lot. Thanks

    1. Istiak Rayhan Avatar
      Istiak Rayhan

      Glad I could help.

  8. Muminur Avatar
    Muminur

    You might have missed one thing, make search page attribute >> Page without sidebar. Will help you earn more.

  9. Akash Deep Satpathi Avatar
    Akash Deep Satpathi

    Thanks for the tutorial!

    Recently after thinking about adding this I was get confused on how to add it to my site which search within my site.

    Really helpful article, as always!

    —
    Akash.

    1. Istiak Rayhan Avatar
      Istiak Rayhan

      Glad it helped. Stay Connected!

  10. Amrish Avatar
    Amrish

    Thanks for the great tutorial . I was looking for this for a long while . I have seen many popular bloggers are using this like shoutmeloud.

  11. sabrina Avatar
    sabrina

    does it mean who will enter text in search bar, the website owner will earn some $$ ? sorry i m newbie to wp

  12. Suresh Khanal Avatar
    Suresh Khanal

    Nice tutorial with illustrations. Custom search is, in my opinion, a must and you can’t rely on WordPress default search.

    I wonder how you removed the ‘Google Custom Search’ brand on the search form. I guess Google attaches it along with the search form. Did you remove the code?