Search feature is a major requirement in any site. Its not easy to keep on searching in archive of any site. In this article we will learn how to implement AdSense search results within WordPress Pages. Making money is another part of it. This question was asked to my by Shankar after he saw its implemented on my site. Prior to starting this tutorial I don’t take any responsibility if any article similar to this is already written. I have done it with my own experience.
Here are the steps which we will follow.:-
- Making a Page on your WordPress blog.
- Creating Adsense code from Adsense account by Google Adsense for Search.
- Understanding , Creating a template file for Search Page and Adding Adsense Code
- Applying the template to the page you created in 1st step.
Create a page in your WordPress blog:
Its an easy step.
- Login to your WordPress admin area.
- Go to Manage > Write > Write Page.
- Add a suitable title and page-slug. E.g – Page Title : Site Search . Page Slug – Google-search
- On the sidebar of editor you will find option of adding Template to the page. Leave it as Default.
- Don’t write anything in the page now, Just publish it and exit from it.
Now the note the URL of the page which for an example can be https://www.technospot.net/blogs/blogs/google-search . Make sure its valid.
Creating your Adsense code for search.
Google Adsense allows you to add a form which act as a search box for any site. But there is one constrain with Adsense Search. Your site should be indexed properly if you want search result to be displayed from your site else it can be used for normal search.Follow the steps:
- Now login to your Google Adsense account and go to Adsense Setup > Adsense for search.
- After entering all the details of your site and customization you will get an option like
- Choose the third option and enter the search page URL which you created in previous step for me i.e https://www.technospot.net/blogs/blogs/google-search .
- Now you will get two codes. One for the Search Form and other for search result code , which we will use it for our search page we created.
Understanding template and creating template file for Search Page
A template is something which can be reused again and again. In WordPress template file can be used to add it to Pages. So when the page is called it uses the template along with it. Here we will create template file called as “Search.php”
- Create a template file named as “search.php” on your desktop.
- Now add the below code into it.
- Insert the Adsense code for Search Result inside the commented area.
- Note remember to call header, footer and sidebar. And preferably add your code in the content part.
- Upload the file into the theme folder which you are currently using.
Thanks for the informative post, I am however having trouble adding adsense in the middle of a wordpress post? Could you assist me in doing this? How do you do it? Thanks
Wow, thanks.
I have been wanting to do this for a while and you tutorial was easy to follow and spot on.
Many Thanks
Dan Collins –
The download link “search.txt (rename it as .php file before uploadling)” does not work.
Hi Ashish,
I am Nihar from Niharsworld.com. I got to this page from Google.
I tried integrating custom google search. By creating a search template also removed getsidebar call to remove sidebar but didn’t know how to achieve it.
I hope your solution will work. I will let you know whether i succeeded or not . If don’t then will ask you for some more help.
Thank you very much. I hope to see you on my blog soon!
Great article! I have incorporated this into my own blog. My only complaint was the link to search.txt is broken but it was easy enough to retype.
I purchased some books and cds on internet marketing and implemented the techniques in a couple of my websites. However I somewhat feel that I’m making some mistakes somewhere that is harming my traffic
This won’t work on MOST WordPress templates simply because Google Search requires a column at least 795 pixels wide.
Thanks for sharing. By the way, this is not suite my wordpress template because Google search result require at least 795 pixels wide, like Dave said. I think the better solution is to show search result outside my website.
what are the earnings like using adsense search i was thinking of using it but im not too sure
Thanks Ashish 🙂
It helped me.
I have discovered that you CAN have a width of less than 795 pixels if you choose to NOT have ads on the right. For instance, the option to have ads on the top and bottom allows you to use very small width, such as 600 pixels.
This is exactly what I was looking for. you are the man. Thank god I stopped by your website. Really appreciate.
Much thanks for yet another first-rate post. I am always trying to find good WordPress tricks to recommend to my own readers. Thank you for taking the time to write this tutorial . It’s just what I was looking for. Truly awesome post.