Replace WordPress inbuilt Search Box with Google Customize Search


A few of you might notice that I have replaced the wordpress search box with the Google Customize Search Box. The advantage of using google custom search is that it considers the comments in the search result while the wordpress search engine does not. And, as this blog only allows maximum one post per page, thus showing only 1 item in the search result is not much useful.

Simple HTML code

You can use the following simple HTML code to enable google custome search box. What it does to insert a piece of pure HTML containing a text box and a button (placed in table layout). Once the button is clicked, the query is submitted to google search engine.

<form method="get" action="https://www.google.com/search">
<table border="0" align="center" cellpadding="0">
<tr><td>
<input type="text"   name="q" size="20" maxlength="255" value="" />
<input type="submit" value="search" /></td></tr>
<tr><td align="center" style="font-size:100%">
<input type="radio"  name="sitesearch"
value="helloacm.com" checked />HelloACM
<input type="radio"  name="sitesearch" value="" />Google
</td></tr></table>
</form>

If your site is using SSL, make sure the URL of google is HTTPS instead of HTTP (which is default when you get the code in adsense).

Customization in Adsense

You can add the search box in adsense control panel.

adsense-add-searchbox Replace Wordpress inbuilt Search Box with Google Customize Search adsense beginner HTML5 web programming wordpress

Add customize google search box via adsense

The difference is that it will add a piece of Javascript code that has the watermarks in the search box, and an optional popular query plugin. You can set the search result in a new window, the same page, or inside a frame. On the result page, there are ads and this also increases the ads page views, which in turns increases your adsense earnings. However, according to the Google TOS (terms of service), you can click the search box but you cannot click the ads on the result pages.

Google Webmaster Configuration for Search

One disadvantage of using Google custom search is that the results are not real time, i.e. if you just publish a post, it may not be reflected in the search page most likely. All it depends on the frequency of google search bots accessing and indexing your site.

You might manually adjust this frequency in google webmaster.

google-webmaster-increase-search-frequency Replace Wordpress inbuilt Search Box with Google Customize Search adsense beginner HTML5 web programming wordpress

google webmaster adjust bots speed

One other trivial disadvantage is that the additional Javascript code may slow down the page loading speed, especially in e.g. China where the google service is slow to access.

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
596 words
Last Post: How to Display Blog Statistics at the Page Footer?
Next Post: RandomFloatRange Function in Delphi/Object Pascal

The Permanent URL is: Replace WordPress inbuilt Search Box with Google Customize Search

Leave a Reply