How to add Google Search with WordPress Search

Hi every body! Today, I will inform how to mix Google (Adsense or normal) Search with WordPress search! Well, to do this, you need to have a little coding knowledge. And I believe that you will do it. So, let's start:...

Add Google Search with WordPress

First I will show you how to make a Google Search box. You will find a lot of widgets to attach Google search engine  on your site. But the following will help you to make a search form for both your site and Google search. I mean the search result will be your site contain or other and it will selected by your site user. Well , let's see

Google Search Form:
Both Site Search and Google Search

<form action="http://www.google.com/search" method="get">
<input maxlength="100" name="q" size="31" type="text" />
<input type="submit" value=" Google Search " />
<input name="sitesearch" type="radio" /> Web Search
<input checked="checked" name="sitesearch" type="radio" value="shariarbd.com" /> Shariarbd.com
</form>

The above code will make a simple Google  Search Form. It will display the result on  Google and I looks like the search box on the right site bar of this site. You can copy the search for on your sidebar of WordPress with the text widget. One thing, Replace the Shariarbd.com from the form code otherwise it will show my sites results!

Now, I  will show how to attach Google Adsense Search box with all options what contain the above search form. Follow the code below:

Google Search Form with Google Adsense

<form id="cse-search-box" action="http://www.google.com/cse"> 
<div> 
<input style="color: #ff9900;" name="cx" type="hidden" value="partner-<span style=" />pub-xxxxxxxxxxxxxx:icn8ro1sh2e" /> <input name="ie" type="hidden" value="ISO-8859-1" />
 <input name="q" size="28" type="text" /> 
<input name="sa" type="submit" value="Search" /> 
<span style="color: #99cc00;"> 
<input name="sitesearch" type="radio" /> 
Web Search <input checked="checked" name="sitesearch" type="radio" value="shariarbd.com" /> 
Shariarbd.com</span>
</div>
</form> 
<script src="http://www.google.com/cse/brand?form=cse-search-box&lang=en" type="text/javascript">
<!--mce:0-->
</script>

The above code will not word until you change the colored area with your Google Adsense Publisher ID. Open your Google Adsense account and create AdSense for Search and add the green colored code into the code generated by Google Adsense. Do not forget to replace my site URL otherwise it will view my site results (ha ha ...)

And now, I will show you how to attach the AdSense for Search withe WordPress Search. Click to Editor form the Appearance tab of your WordPress Dashboard (See on the middle of the left side bar of your WordPress dashboard). Now choose Search Form from the right side bar. There you may file the following codes:

<form id="searchform" action="<?php bloginfo('url'); ?>/" method="get">
<div id="searchformwrap">
<div>
<div>
<input id="searchbox" name="s" type="text" value="Search here ...." />
</div>
</div>
<div><button></button></div>
</div>
</form>

It may varies cause of WordPress theme as Search Form is a page inside the WordPress theme folder. If you like to do this manually with your site cpanel, go to your WordPress theme directory and find the searchform.php page and you will got all that thing of the above form. Well, first make a backup of the code shown in the above (It should be your pages code) and then replace the codes with following, I mean your adsense code or the first form if you don't have Google Adsens.

<strong>Google Search Form with Google Adsense</strong>
<form id="cse-search-box" action="http://www.google.com/cse">
<div>
<input style="color: #ff9900;" name="cx" type="hidden" value="partner-<span style=" />pub-xxxxxxxxxxxxxx:icn8ro1sh2e" />
<input name="ie" type="hidden" value="ISO-8859-1" />
<input name="q" size="28" type="text" />
<input name="sa" type="submit" value="Search" />
<span style="color: #99cc00;">
<input name="sitesearch" type="radio" />
 Web Search
<input checked="checked" name="sitesearch" type="radio" value="shariarbd.com" /> Shariarbd.com</span></div>
</form>

<script src="http://www.google.com/cse/brand?form=cse-search-box&lang=en" type="text/javascript"><!--mce:0--></script>

The search result will shown with Google.com and don't worry, it will show your site search result also!




Leave a Reply

Your email address will not be published. Required fields are marked *

*