Feb 11, 2008 @ 12:41 PM
Discuss:
Permanent Link:
Save
Category:
Web
Post to:
del.icio.us
The default WordPress search engine barely qualifies as a search engine. It's results are not that relevant, the search page shows the actual blog entries instead of a list of links of resulting pages and the experience gets worse if the search query gets the least bit creative.
I think everyone should deprecate the WordPress search engine and move to Google Custom Search. There is simply no comparison. You can see the search results for AJAX on my website.
How-to for Google Custom Search Implementation in WordPress
Having recently implemented it on my site I don't think it gets much better than this. Implementing it in WordPress is trivial and the results are of the highest quality.
- Head on over to http://www.google.com/cse/ and register for an account. Follow the prompts all the way until asked to select the kind of layout/code options.
- The best Google Custom Search configuration I think is to select the iframe option with advertisements placed on the right. Secondly, you will want to specify the search results url as something like http://yourdomain.com/search.php. More on that in a minute.

- Subsequently you will be shown two textarea's. The first one is the search box code which shows the input field where queries are entered. You can paste this code in your header or index template (header.tpl or index.tpl in the wp-content/theme/ directory) depending on where you want the box to show up.
- The second code box is for the search results page. To display the Google Custom Search results on a fresh page, create a file called search.php in the root of your web directory (this corresponds to the results url you entered above). Within this page you should paste both code snippets. The Google Custom Search box code will display the search box to the users once again so they can see their own query. The Custom Search results code will display the actual results below the box. This is what your search.php will look like:
PHP:
-
<?php
-
// these two lines get the theme page initialization code and header
-
require('./wp-blog-header.php');
-
get_header();
-
?>
-
-
<!-- Google CSE Search Box Begins -->
-
...
-
<!-- Google CSE Search Box Ends -->
-
-
<!-- Google Search Result Snippet Begins -->
-
...
-
<!-- Google Search Result Snippet Ends -->
-
-
<?php get_footer(); ?>
- That's it, you're done.
Your page won't be instantly indexed and may take a day or two, but that's a small price to pay. And if you show your 5-10 most recent blogs in the sidebar then you're good anyway because users can navigate directly.
i think this is the best solution for a wordpress blog and should be on top of the google search results instead of those from seomoz and dosh dosh who is not of help and was a very naive tutorial for wordpress blogs.there tutorial was not for wordpress blogs. imagine, they said that the “google search results code should just be pasted on a wordpress page made. as in one should just create a page and paste it just like in making a blog post!!! how ignorant. you just don’t have to justr paste the code just like that because it will not work that way for wordpress. imagine seomoz and doshdosh teaching that!!
your tutorial is the correct tutorial. great work!
Comment by Get it From Boy! — July 27, 2008 @ 1:30 pm
Many thanks sir!
This was just what I was looking for - and it works fine! Although I did need to pop a formatting in to get everything to stay within the boundary of my fixed width site.
All the best,
Alex
Comment by Alex — July 6, 2008 @ 8:01 am
This is one of the rarest & the BEST explanation of implementing the Google Custom Search. I have compared a few other’s and this is way better than the other tutorials. I have implemented it on http://www.prodigitaltips.com/ just by following this post step by step. Well I have some problem with the footer, but I will probably get through that too.
Great post.
Cheers! Jay
http://www.prodigitaltips.com/
Comment by Jay — June 20, 2008 @ 3:12 pm
Nice & helpful post. I tried a search on your website & the results returned with an error on the top of the page (some permission issue). You may like to check that.
Cheers!
Jay
http://www.prodigitalblog.com/
http://www.prodigitaltips.com/
Comment by Jay — June 20, 2008 @ 6:40 am
Thanks, Aleem! it worked! just check my website at http://www.recipes4busymoms.com
Comment by Maria — March 11, 2008 @ 9:49 pm
hi..thanks..i would like to try this solution. I tried “On Google hosted page” as hosting options with black color as background. I dropped the code in Text1 widget on my sidebar. Now issues is as my site background color is black, i cannot see when i type in search box. If you would suggest me, it will be appreciated.
Comment by redson — March 3, 2008 @ 1:52 pm
[...] thanks to Aleem Bawany for tips on how to do [...]
Pingback by Google Custom Search at nyc.locationscout.us — February 25, 2008 @ 10:01 pm