Home > 博客心得 > 终于是时候彻底告别WordPress自带的搜索了

终于是时候彻底告别WordPress自带的搜索了

June 10th, 2009

Google早就提供自定义搜索的功能,可惜又要申请代码又要改模板的,我倒是尝试过,最后撤了,嫌麻烦,继续用WordPress自带的慢吞吞搜索,不过现在……

Google大神又提供了一个添加自定义搜索到WordPress侧边栏的方法。当然了,这个方法不限于WordPress,适用于任何网站。而且简单得令人发指。

终于终于是时候彻底告别WordPress自带的搜索了,Yeah!

第一步:把以下代码添加到一个Widget里面,所有网站都一样,不用去申请不同代码。

<!– Google Custom Search Element –>
<div id=”cse” style=”width:100%;”>Loading</div>
<script src=”http://www.google.com/jsapi” type=”text/javascript”></script>
<script type=”text/javascript”>
google.load(’search’, ‘1′);
google.setOnLoadCallback(function(){
new google.search.CustomSearchControl().draw(‘cse’);
}, true);
</script>

第二步:Ooops,没了,简单吧。 效果见网贝侧边栏。如果你还没见过这个效果,请一定要看一下,超炫超强的。

,

10 Tweets 3 Other Comments

  1. Yixin
    June 10th, 2009 at 23:32 | #1

    太好了!结果也在侧边栏,好

  2. toopoo
    June 11th, 2009 at 02:08 | #2

    测试搜索“绿坝”,1?没反应 不好用啊
    然后测试搜索“测试” 哈哈 出来了 太搞了

  3. June 11th, 2009 at 02:57 | #3

    如果不带 powered by Google就更好了。

  4. June 11th, 2009 at 04:16 | #4

    我也加上代码了。
    效果倒是比较炫,不过准确度似乎不够高,广告也是有时候出现有时候不出现。
    btw: 这个自定义搜索的获知来源是哪里呢?

  5. June 11th, 2009 at 04:38 | #5

    不错……不过还是不打算用

  6. June 11th, 2009 at 04:38 | #6

    #bookmark 添加Google自定义搜索到侧边栏的最简单方法 | 网贝|BT’s homeland http://tinyurl.com/nm23rl

    This comment was originally posted on Twitter

  7. June 11th, 2009 at 04:50 | #7

    貌似你用的是mac 字真好看

  8. June 11th, 2009 at 04:55 | #8

    终于是时候彻底告别WordPress自带的搜索了 http://ff.im/-3PU8J

    This comment was originally posted on Twitter

  9. June 11th, 2009 at 05:00 | #9

    这下方便了

  10. June 11th, 2009 at 05:01 | #10

    这个的确强大,一定要试试。

  11. June 11th, 2009 at 05:18 | #11

    找时间折腾一下 :-P

  12. June 11th, 2009 at 05:19 | #12

    这个主题貌似自带Google自定义搜索啊

  13. June 11th, 2009 at 06:01 | #13

    赞!这个方法简单!

  14. June 11th, 2009 at 06:34 | #14

    [GShare] 终于是时候彻底告别WordPress自带的搜索了 http://bit.ly/6yP4k

    This comment was originally posted on Twitter

  15. June 11th, 2009 at 06:56 | #15

    简单多啦.真棒!

  16. June 11th, 2009 at 06:59 | #16

    真是简单到令人发指!

  17. June 11th, 2009 at 07:04 | #17

    这个好玩,我去折腾下~~

  18. June 11th, 2009 at 07:06 | #18

    奇怪啊,我那里怎么总是loading呢?

  19. June 11th, 2009 at 07:35 | #19

    终于是时候彻底告别WordPress自带的搜索了 http://ff.im/-3Q9h3

    This comment was originally posted on Twitter

  20. June 11th, 2009 at 07:47 | #20

    终于是时候彻底告别WordPress自带的搜索了 http://ff.im/-3QaCX

    This comment was originally posted on Twitter

  21. Harley
    June 11th, 2009 at 08:00 | #21

    我那里也总是loading,我放在text的Widget里的

  22. June 11th, 2009 at 09:11 | #22

    @盆地
    我觉得是就是google搜索的site:吧

    @eddie
    不是啦,呵呵,是GDI++

    @老N
    @Harley
    你们俩是不是用了no script之类的东西啊

  23. June 11th, 2009 at 09:26 | #23

    @blacktulip
    可能我的问题没有说清楚,我的意思是指这种方法是自己发掘的,还是在哪里给出的。我记得adsense的搜索是没有这种的。
    另外,这个搜索结果在某些情况下是会有广告的,比如在你的博客中搜索”WordPress”,不知道这个广告点击的收入算谁的?因为这个代码中没有adsense的id,所以恐怕是不算站长的吧。

  24. June 11th, 2009 at 09:29 | #24

    @盆地
    哦哦,这个,我用了有adsense的代码,文章里面给的是没有adsense的代码,呵呵。
    忘加链接了,已经加上

  25. June 11th, 2009 at 09:29 | #25

    在博客侧边栏添加 Google 自定义搜索的办法 http://bit.ly/RIhTa

    This comment was originally posted on Twitter

  26. June 11th, 2009 at 10:51 | #26

    @blacktulip
    对cutstom search没怎么注意过,谢谢发掘了个这么好用的东西,呵呵

  27. June 11th, 2009 at 12:50 | #27

    好啊.不过原来得WP搜索怎么处理掉呢?

  28. June 11th, 2009 at 14:38 | #28

    @Ranel
    到模板里面直接注释掉, 我是这么干的,呵呵

  29. Harley
    June 11th, 2009 at 18:01 | #29

    @blacktulip
    没有noscript,你的显示正常,我自己的出不来啊

  30. June 11th, 2009 at 21:41 | #30

    @Harley
    到google那里去拷贝代码吧,呵呵,那个链接里头,试试看那样行不行

  31. Harley
    June 12th, 2009 at 02:36 | #31

    好了,可能是你的adsense代码的问题,呵呵

  32. June 12th, 2009 at 06:18 | #32

    你用的inove可以在后台直接设置启用google搜索,不用这么麻烦啊

    我来问你启用了backtype插件后有没有发现inove用这个插件好像有问题,有时候自己的头像会跟读者的一样都靠到左边去了。

  33. June 12th, 2009 at 06:19 | #33

    呃,好像你这个效果更好一些

  34. June 12th, 2009 at 06:40 | #34

    还是喜欢搜索内容显示在正文区~

  35. June 12th, 2009 at 09:34 | #35

    @kerby
    应该不是插件的问题,有时用另一个邮箱的话,头像就会上左边去

  36. June 12th, 2009 at 11:06 | #36

    真leeeeeet

  37. June 13th, 2009 at 03:30 | #37

    很炫,但还是不太适应搜索结果在侧栏,感觉太拥挤了

  38. June 15th, 2009 at 06:52 | #38

    很好,我喜欢谷歌。

  39. June 15th, 2009 at 06:53 | #39

    我是在想,博客里面的搜索大多数是用来摆设的.除非网站内容很多\流量很高.

  40. June 16th, 2009 at 10:12 | #40

    请问,怎么可以删除呢?

  41. June 16th, 2009 at 10:44 | #41

    @David
    删除什么啊?

  42. June 22nd, 2009 at 07:18 | #42

    用上了,谢了,的确简单强大到可怕!!

  43. June 22nd, 2009 at 07:19 | #43

    @David
    如果是删除搜索结果的话,点Search右边的X就好了

  44. June 22nd, 2009 at 07:29 | #44

    非常不错的样子嘛.也来试试.

  45. August 2nd, 2009 at 15:02 | #45

    我现在还在使用Google的自定义搜索。。
    我记得你以前不是用这个主题的,啥时候换上的。

  46. August 8th, 2009 at 08:14 | #46

    这个是Google AdSense的搜索一样吗?

  47. September 22nd, 2009 at 21:15 | #47

    确实方便多了,但是我用的主题是集成了搜索的。。

  48. December 14th, 2009 at 01:08 | #48

    貌似比我现在那个好用!

  1. June 11th, 2009 at 07:29 | #1
  2. August 27th, 2009 at 17:12 | #2
  3. December 1st, 2009 at 03:29 | #3
  4. December 8th, 2009 at 03:26 | #4

Additional comments powered by BackType