< Browse > Home / How-To Tips, The Internet / Blog article: Use Adsense for Search in your Wordpress Search

| Mobile | RSS

Use Adsense for Search in your Wordpress Search

November 8th, 2008 | 1 Comment | Posted in How-To Tips, The Internet

Replace Wordpress Theme Default Search with Google’s Adsense for Search.

I’ve been trying to use adense for search since I changed my themes several times already in just a few months but I was not successful not until now. 

 

Steps to add search page in your blog:

  1. Login to your Adsense account and go to Adsense Setup and then select Adsense for Search. 
  2. Select Search type Google either Site search or the entire web. Of course I choosed Only sites I select then add add my website in the selected sites box since I only want to search within my website.
  3. Customize your adense for search. I normally use the default settings.

    In Wordpress 
  4. Make new blank page in Wordpress and name it anything you want (lets use google-search for example) then save it.
  5. You will now have this link: http://yourwebsite.com/google-search take not of it.

    Back to Adsense
     
  6. Proceed now to Search Result style and look for Open results within my own site then check the radio button. Then enter http://yourwebsite.com/google-search in the box provided.
  7. Finish up your customization adn get your Google Adsense Code for search. You will get code for the search form and for the search result. Save it for later use.

    back again In Wordpress
  8. Now download MightySearch wordpress plugin and activate it. This plugin is just made for inserting google search results in your blog.
  9. Copy your adsense for search code in their corresponding box in MightySearch Plugin settings.
  10. Edit the page you recently made (google-search) then choose HTML instead of visual and paste this code: <!–mightysearch_result–>

    the hard part
  11. Now go to your wordpress theme you are currently using then open and edit header.php
  12. Look for tha part: <form method=”get” id=”searchform” action=”<?php bloginfo(’home’); ?>/”> 
  13. Replace the action part with the code you got from google. (eg. <form method=”get” id=”searchform” action=”http://yoursite.com/google-search” id=”cse-search-box“> )
  14. after the <div id=”search”> tag, add the following similar to this:
     
    <input type=”hidden” name=”cx” value=”partner-pub-your adsense id” />
     <input type=”hidden” name=”cof” value=”FORID:11″ />
     <input type=”hidden” name=”ie” value=”ISO-8859-1″ />
    <input type=”text” value=”Enter search keyword” onclick=”this.value=”;” name=”q” id=”s” />
    <input name=”sa” type=”image” src=”<?php bloginfo(’template_directory’); ?>/images/searchbutton.png” value=”Search” class=”btn”  />   

    ==== Here’s the original code from the theme ====
    <form method=”get” id=”searchform” action=”<?php bloginfo(’home’); ?>/”>
    <div id=”search”>
    <input type=”text” value=”Enter search keyword” onclick=”this.value=”;” name=”s” id=”s” />
    <input name=”" type=”image” src=”<?php bloginfo(’template_directory’); ?>/images/searchbutton.png” value=”Go” class=”btn”  />

  15.  Save your header.php then try now using search.

You will notice that you have google-search title in your page navigation. You can try to unpublish or make the page private so it won’t show on your page navigation but the adsense for search might not work. You can try these steps that worked for me.

  1. Edit google-search page title to blank (remember, only the title and not the link. You can also add space if it does not save)
  2. Set the google-search page order to the last so it will not affect the positioning of the other pages.
  3. Save it and you are all set.

Leave a Reply 18 views, 1 so far today |
Follow Discussion

One Response to “Use Adsense for Search in your Wordpress Search”

Trackbacks

  1. Adsense for Search - 7 reasons to give it a try.. | Nikhil Gupta - making money online blogging tips  

Leave a Reply