So you want to integrate AdSense for search in your WordPress blog. Here’s a detailed step by step tutorial. Just follow each step as explained and you’ll have the AdSense for search on your WordPress site.
1. Login to your Adsense account and go to, AdSense Setup > Get Ads > AdSense for Search.
2. Click on the link that says Single Page. This will make it easier to customize your AdSense for search code as everything will be on a single page.
3. For search type, keep the ‘Only sites I select’ option selected.
4. In the Selected sites text box, enter you domain like this,
5. Leave the ‘Optional Keywords’ box empty.
6. Keep the default values for ‘More options’ and ‘Search Box Options’ settings.
7. For search results styles, select the option that says, ‘Open results within my own site’. Then enter the URL http://www.yourwebsite.com/search.
Adjust the page width according to the width of your WordPress theme.
8. Keep default values for ‘Ad Locations settings’ and ‘color settings’, agree to AdSense terms, enter a name for your AdSense seacrh engine and click on ‘Submit and Get Code’ button.
Adsense will generate two code snippets for you. One which must be used to create a the search box, and another to display search results.
That’s it for the AdSense interface. Keep the codes page open as we will need both codes later.
9. Login to your WordPress blog and go to ‘Appearance > Editor’.
10. Find out the search box code of your theme. It will be either in searchform.php or header.php file. It will look something like this code,
<div><input type=”text” size=”18″ value=” ” name=”s” id=”s” />
<input type=”submit” id=”searchsubmit” value=”Search” class=”btn” />
Replace this code with the search box code (the first code snippet) you got from Adsense.
11. Now to display the AdSense for search results, you must create a custom search results template file. To do that login to your WordPress site via FTP and download the template file page.php from your theme’s folder, and add this code at the top of it,
Template Name: Search Results
Save this file with the name search-results.php.
12. In search-results.php file, delete everything between the main content area of this file. For example, if you are integrating AdSense for search on the twentyten theme, delete all the code between
<div id="content" role="main"> and its corresponding closing div, and paste the second code snippet from the Adsense in between.
13. Now upload search-results.php file in your theme folder.
14. Create a new page with the name ‘Search’, choose page template as Search Results,
Now publish this page. Yes publish the empty page.
15. That’s it. Now try to search something in the newly integrated AdSense for search and you should see the results immediately on the search results page.
If you are uncomfortable editing the template files, or if you feel that an expert WordPress developer should handle the integration, then you can hire me to integrate AdSense for search on your blog.
I am not able to locate search result template. Only default template is visible. Do you have any idea what to do now.
If you don’t have a search template in your theme, then make a copy of index.php file and rename it to search.php.