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
- 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.
- Google account to create and manage your search engine(s).
- Understanding of WordPress theme structure and tools+skills needed to create and edit template files.
- Create a AdSense for Search in your AdSense account (of course).
This will give you two part of the code, one for search box and one for search results:
- 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.
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).
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:
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.