How To Implement Google Custom Search Into A WordPress Blog - ManageWP

How To Implement Google Custom Search Into A WordPress Blog

The default WordPress search engine serves up poor quality results to your blog visitors, which can drive otherwise engaged people away. Solve the problem by following this simple step by step guide to implementing Google Custom Search on your blog!

How To Implement Google Custom Search Into A WordPress Blog

There is something you should know about WordPress’ standard search feature – it is awful. For anything more than the most basic of blogs, it is extremely limited. It sorts results by reverse chronological order (rather than by relevance), and shows by default the first 55 characters of a page or post (rather than a relevant excerpt).

This is a big problem for any WordPress blogger, because people are used to finding things by searching. Navigation elements are all well and good, but many people will never go near a category link or a tag. Wen surfers have been conditioned to search by default.

The crux of the issue is that people want to search, and they expect quality results. They have been spoilt by Google. Meanwhile, the WordPress search engine generally returns poor quality (and even irrelevant) results.

The Solution

Fortunately, there is an ideal solution – Google itself. The world’s most popular search engine gives you the tools with which you can create your own customized search engine for your site alone.

The bad news is that creating your own custom search engine and integrating it with your site is somewhat complicated. The good news is that the Google Custom Search plugin will do all of the hard work for you. You can have Google-powered search on your site within minutes – the following is a step by step setup guide.

1. Create a Custom Search Engine

Once you have downloaded, installed and activated the Google Custom Search plugin, you need to create your search engine. Fortunately, this is not a complicated procedure. Head over to this page and fill in the relevant information. You will of course want to enter your blog’s full URL where requested.

You will no doubt note the two different “Editions” on offer – the free version (with advertising), and the paid version (without advertising). Advertising is the price you pay for quality search results – unless of course you are prepared to fork out for the paid version.

Once you have made your choice, check the box to agree to Google’s Terms of Service and hit “Next”.

2. Select Your Style and Test Your Search Engine

Google offers up a variety of different “styles” for your search engine:

Search Engine Style

The Default style is most reminiscent of Google’s own search engine results, so we would recommend that you stick with it (for usability’s sake).

Once you have made your selection, you can test out the search engine by entering a query into the search box. You should take this opportunity to make sure that relevant results are being returned. Only posts and pages that have been indexed by Google will appear in the search results.

Once you have made sure that you are satisfied with the results, it is time to move onto the next step.

3. Extract the Search Engine Unique ID

On the subsequent page, you will be presented with a text box full of code. We are only interested in extracting the search engine unique ID, highlighted below:

Search Engine Unique ID

If you are in any doubt as to whether or not you have the correct ID, you can also find it by accessing your search engine’s control panel on this page.

Once you have extracted the ID, head over to the Google Custom Search plugin’s settings screen and paste it into the relevant box:

Google Custom Search Plugin Settings

Hit “Save Changes”, and the setup process is complete!

4. Create Your Search Box

The final step is of course to create a search box. You have two options.

The first is to create it in widgetized area, simply by dragging and dropping the “Google Custom Search” widget.

The second is to include the search box anywhere in your blog’s theme by pasting the following PHP code:

<?php display_search_box($display_results_option); ?>

You need to replace $display_results_option with one of the following:

If you choose display_results_custom, you need to stipulate where the results should be displayed by entering the following PHP code in the desired location:

<?php display_gsc_results(); ?>

Congratulations! You now have Google Custom Search on your WordPress blog.

Alternative Options

Although the Google Custom Search plugin is an extremely straightforward solution, it may not be to your liking. You may in fact want to integrate search results into your theme’s template, rather than returning the results in a lightbox:

Search Engine Results Page
An example of the lightbox search engine results page

It certainly is possible to do this – if you have a rudimentary understanding of PHP and an hour or so to spare, just follow this excellent guide.

If on the other hand you want a quick and easy alternative to WordPress’ default search engine, Google Custom Search is a fantastic option.

What Do YOU Use?

There is no doubting the importance of search in increasing the usability of your website. With that in mind, what tool do you currently use? Have you been using WordPress’ default search engine, and if so, are you now going to make the switch? Or do you use one of the many alternatives and prefer it to Google Custom Search? Let us know in the comments section!

Tom Ewer

Tom Ewer is the founder of He has been a huge fan of WordPress since he first laid eyes on it, and has been writing educational and informative content for WordPress users since 2011. When he's not working, you're likely to find him outdoors somewhere – as far away from a screen as possible!


  1. david


    Im looking for GCSE experts to implement in my website [fullwidth template design on wordpress]


  2. pravP


    Thanks for this wonderful article and bookmarking your blog for further reference.


    1. Tom Ewer

      Glad you enjoyed it :-)

  3. Maneksh

    i think plugin is a good option

    1. Tom Ewer

      Thanks Maneksh!

  4. moneystepper

    Great tutorial. I’ve just added it to my site now. Thanks Tom.

  5. Erik Eng

    Great tutorial. A much cleaner solution is to use this plugin to serve search results in the default search listing.

    1. Tom Ewer

      Wonderful suggestion Erik! It seems I’m credited in some way for it too…not sure why!

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>