How to Integrate Google Search Into WordPress Blog

image There are some valid reasons to do this, mainly to provide better and familiar experience to readers, so it is popular tweak.

Why bother

WordPress has native search implemented, but it has considerable shortcomings:

  • quality of search results is often questionable;
  • there is no control over it from admin interface;
  • search is resource-intensive operation by itself, which might stress budget hosting and was reported as vulnerability to denial of service attacks.

Switching to Google search is by no means perfect, but does provide:

  • familiar user experience;
  • good quality of search results;
  • monetization of search results;
  • takes performance issues off your host.
What you need
  1. Your site should be indexed by Google. There is an option of enforced indexing for search purposes, but it is limited. It is best to have properly indexed site anyway.
  2. Google account to create and manage your search engine(s).
  3. Understanding of WordPress theme structure and tools+skills needed to create and edit template files.
Quick Implementation
  • Create a AdSense for Search in your AdSense account (of course).

image

image

image

This will give you two part of the code, one for search box and one for search results:

image

  • Now, you need to create a template page where Google searches will land. Once you create a php template file you need to upload to your Theme folder in your web server.

image

I have also inserted the Search Box Code in the header.php file, which is the file that contains the search box (which is getting replaced).

image

NOTE: I have also added the header and the footer of the template because I wanted to look like the WordPress Theme.  You can find more information about creating templates here: http://www.myw0.com/2010/2134/how-to-create-a-custom-wordpress-page-template/

  • Finally, create a page in WordPress and link the page to the php-template-file that was uploaded. here are few images:

image

image

 

NOTE: The WordPress page has nothing but just link to the php-template-file. If you site has not been index by Google then it may not bring any results, just way few days or hours so that Google can catch up. You can also use the Webmaster tools of Google and then submit you sitemap.xml.