How to Put Custom Google Search on Your Mistylook Theme
January 2nd, 2007 by Andrew Chen
I have spend quite some time lately to set up my blog and try to make it different from other blogs that are using the same theme. But it doesn’t look much different. You can tell it is still a mistyook theme which you can download from here. There are two changes I made to the theme. I added the random header image. The header image changes every time a page is reloaded. I explained how to do it in this post. The second thing is that I replace the original wordpress search box with custom Google search.
In order to do that a new template file need to be created in the mistyook folder. You can name it search_results.php. Open the file in notepad and put the following code in there:
< ?php
/*
Template Name: Search Results
*/
?>
< ?php get_header(); ?>
<div id=”content”>
<div id=”content-main”>
< ?php
$searchstring = (!empty($_GET['q'])) ? "Search Results For '".$_GET['q']."'" : "Please Enter Your Search Phrases";
?>
<h2 class=”pagetitle”> < ?php echo $searchstring; ?> </h2>
<!—- Google Search Result Snippet Begins —->
<div id=”googleSearchUnitIframe”></div>
<script type=”text/javascript”>
var googleSearchIframeName = ‘googleSearchUnitIframe’;
var googleSearchFrameWidth = 510;
var googleSearchFrameborder = 0 ;
var googleSearchDomain = ‘www.google.com’;
</script>
<script type=”text/javascript”
src=”http://www.google.com/afsonline/show_afs_search.js”>
</script>
<!—- Google Search Result Snippet Ends —->
</div>
< ?php get_sidebar(); ?>
< ?php get_footer(); ?>
After that you will need to modify the header file header.php. Replace the following line
<li class="search"><form method="get" id="searchform" action="your blog URL“><input type=”text” value=”" name=”s” id=”s” /><input type=”submit” id=”searchsubmit” value=”Search” /></form></li>
with these few lines
<li class="search">
<!– SiteSearch Google –>
<form method=”get” id=”searchform” action=”<?php bloginfo(’home’)?><?php echo “/search-results/” ?>” target=”_top”>
<input type=”radio” name=”sitesearch” value=”" <?php if($_GET[’sitesearch’]!=”your domain“){echo “checked=”checked”"; } ?> id=”ss0″/>Search The World <input type=”radio” name=”sitesearch” value=”your domain” <?php if($_GET[’sitesearch’]==”your domain“){echo “checked=”checked”"; } ?> id=”ss1″/>Search Siusic Only <input type=”text” name=”q” maxlength=”255″ value=”<?php echo $_GET[’q'] ?>” id=”s”/><input type=”submit” name=”sa” value=”Search” id=”searchsubmit”/>
<input type=”hidden” name=”domains” value=”your domain“/>
<input type=”hidden” name=”client” value=”your adsense account“/>
<input type=”hidden” name=”forid” value=”1″/>
<input type=”hidden” name=”ie” value=”ISO-8859-1″/>
<input type=”hidden” name=”oe” value=”ISO-8859-1″/>
<input type=”hidden” name=”cof” value=”GALT:#265e15; GL:1;DIV:#aaaaaa; VLC:265e15; AH:center;BGC:FFFFFF;LBGC:336699;ALC:265e15; LC:265e15;T:000000; GFNT:265e15;GIMP:265e15; FORID:11″ />
<input type=”hidden” name=”hl” value=”en”/>
</form>
<!– SiteSearch Google –>
</li>
Remember to change “Your domain” in the code to your own domain and change “your adsense account” to your own adsense account. After that you need to create a new page using the created template and you will need to go to mistylook options to hide the page from navigation. When all these are done you should able to see it works. Be sure to make a copy of the original file before making any changes.


Hi all!
Very interesting information! Thanks!
G’night
THanks a lot. But, google search now have a new script