Having played with this recently, here is a quick guide before I forget it. I had to use a little trick, I am not sure if there is an easier way to set it up.
All right, let's get started. We want to use Google Custom Search since your blog deserves better search than the one that comes with WordPress.
First go to Custom Search page and setup the new engine. Option worth noting is Advertising status where you can disable ads if you are non profit.
Once done click 'Code' Page, select 'Host results on your website', and iframe option. Enter your site URL.
This will give you two codes.
First one is the one that you need to put in place of your search form. Find the form in your template, usually in sidebar.php or searchform.php.
Here comes the trick. You need to add the following code into the form:
<input type="hidden" name="s" value="Search" />
This is important because it triggers the WordPress search page (search.php).
Now open search.php and replace what you had before with the code in the second box from Google.
Basically you are done now.
You can do more thing. Add this to the top of your header.php:
<?php $s=$_REQUEST['q']; ?>
Now your theme will display the correct value for search term.
This is really a WP hack - I am not saying it's the best or easiest way to do it.
You can even add the search button in your posts. Go ahead and try it out.
Suggested reading:
- How to use custom page template in WordPress themes
- Improve Search Engine Placement with Tags
- SEO Smart Links and Category Search plugins
Posted in: WordPress
TAGS:add custom google search, add custom search blog, add google, add google box, add google search website, add search box pages, custom google search, embed google search website, google custom search php, google search custom engine, google search wordpress blog, how add custom searches, paid custom google search, searchpages php searchbox email, wordpress google custom search, wordpress google search






11 Comments
how do i delete built in search gadget plz help???
you can see my blog template...... mobilemillion.blogspot.com
oh my.. your article was really awesome... thanks yoo..
The easiest way to add a search engine to your site is to use this code. Just plop it in your website.
This will search the whole internet (in another window)
<!--
-->
If you need code to search your whole website, or you want it to open the search results in the same window, as your search bar, I would need more information to build the code. Its pretty easy. Just email me at: [email]shockwave13@gmail.com[/email] and I will help you build the code.
Cheers
I know that you have already set this up for us with your Amazing Grace/Blue Grace themes.
My question is how do we tweak the code to add AdSense for search?
Done!
I recommend anyone who does this, to go a step further and mix it with analytics. Google makes it really easy, just look for it.
I suppose you can, but it does say (for registered non-profits, universities, and government agencies only).
Technically, I think you're suppose to pay a subscription fee to turn off ads.
There is an option to turn off ads right there.
The only issue I have with this tweak (the free one) is how Google places paid ads in the search. So if you have a product you're trying to sell, say web design, and someone goes to your search and types in "Web Design", they will see the results of your competitors before yours (in the paid search area at the top of the returned results).
Not so ideal.
But if you fork over the $100/yr. subscription for Google Search, then no worries, but is it work it?
When I installed the google site search (from adsense) on my myanmar2day site, I tried to make it appeared within my site design. After a few trials and errors, I succeeded. I put the google ad search box in the side bar and direct it to open in the "search" page. Then, I put the google's search result code in the "search" page, and make it hidden in the header links. This solve the problem.
I probably made it in even less proper way - threw out everything related to WP native search and sticked in CSE search form and templated page with CSE frame.
Seems to work except Opera is having minor display error with iframe I failed to fix (so far).
Thanks Vlad--you are a treasure!