I have searched a few blogs in the hope to find a good way to use Adsense for Search to replace default WordPress search. All the solutions suck, they either ask users to add redundant plugins that doesn’t do the job at all or ways to create a static page to display search results. I got really fed up with these ’solutions’ and finally decide to make my own easy to implement method.
1. Create the Adsense for Search unit from adsense website (I don’t wanna write the steps here because Google has been doing a great job providing step by step guide to create the search unit).
2. When you complete the steps to create the unit on Adsense, you shall get two parts of the generated code, Search Box Code and Search Results Code, copy the Search Results Code.
3. Go to your blog admin, Create a Page called Search Results,
4. Paste the Search Results Code you just copied into the textarea.
5. Get the page id, the page id is the digits at the end of your edit page url, for instance, if the page editing url you are creating your Search Result page is http://www.yourblog.com/wp-admin/page.php?action=edit&post=739, then your post id is 739.
6. Publish the page.
7. Go to Design->Theme Editor, from the template pages, select Header.php, and search for the line similar to the one below:
wp_list_pages(’title_li=&depth=1′);
8. Change the line above to the one below and save the file:
wp_list_pages(’title_li=&depth=1&exclude=739′);
739 is a generic number, it’s the Search Page Result id.
9. Open your template file Sidebar.php, at the place you want the Search Box to appear, paste the Search Results Code at the area. And save the post.
10. Now you are done! It requires neither a static page (in the dynamic world, why need a stupid static page?) nor plugins. Just the simple implementation above! Hope this helps :)




















































