How to Integrate AdSense for Search into Mystique WordPress Theme
Posted on 15. Apr, 2010 by Dgrut in Themes, Tips n trik, Wordpress

The following is a tutorial to integrate Adsense into the search for Mystique WordPress Theme. Previously you had to have a Adsense account to get the Adsense Search Code. After getting Adsense Search Code, create a page to display search results from Adsense (Google Custom Search). Paste the following code into the page :
<div id="cse-search-results"></div> <script type="text/javascript"> var googleSearchIframeName = "cse-search-results"; var googleSearchFormName = "cse-search-box"; var googleSearchFrameWidth = 910; var googleSearchDomain = "www.google.com"; var googleSearchPath = "/cse"; </script> <script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script>
The above code will be applied to the template without the sidebar (1 column), because the best view from Adsense Search Require 785px wide.You can change it but do some experiments to fit the width of your blog. If necessary to add the search page with a search form by adding the following shortcode : [widget class="WP_Widget_Search"]
When page is done, go to the Appearance >> Editor then look for core.php
Find this code:
<div>
<form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
<fieldset>
<div id="searchfield">
<input type="text" name="s" id="searchbox" value="<?php _e("Search","mystique"); ?>" />
</div>
<input type="submit" value="" />
</fieldset>
</form>
</div>
Replace with:
<div>
<form method="get" id="searchform" action="YOUR_SEARCH_PAGE_URL">
<fieldset>
<div id="searchfield">
<input type="hidden" name="cx" value="ADSENSE_GENERATED_ID" />
<input type="hidden" name="cof" value="FORID:10" />
<input type="hidden" name="ie" value="ISO-8859-1" />
<input type="text" name="q" id="searchbox" value="<?php _e("Search","mystique"); ?>" />
</div>
<input type="submit" name="sa" value="" />
</fieldset>
</form>
</div>
Need to replace :
- YOUR_SEARCH_PAGE_URL = with your search page url that has been made previously (with http:// included )
- ADSENSE_GENERATED_ID = with your generated id from adsense
Save and test search..
Related posts:

Wordpress Themes
Jul 13th, 2010
Good post and this mail helped me alot in my college assignement. Thanks you on your information.