整合 Google 自定义搜索到 WordPress 中
April 29th, 2008 Denis
整合 Google 自定义搜索到 WordPress 中好像有很多好处,可以减少数据库查询,因为搜索结果是 Google 提供的,不用再去数据库中搜索了。能够更加全面的搜索,WordPress 目前只能搜索 post。另外还可以在搜索结果中绑定 Google Adsense 赚钱。嗯,很爽,那么如何整合 Google 自定义搜索到 WordPress 中。步骤如下:
1. 在 WordPress 中创建一个页面,然后再在导航栏中设置为不显示该页面,如果你是用 wp_list_pages() 这个函数输出页面的,你可以使用 exclude 这个参数把刚才创建的页面剔除出去。
2. 登录到 Google 自定义搜索,创建你的自定义搜索。
3. 在输入你的基本信息和网站之后,来到代码 tab 页面。详细配置如下:
4. 搜索结果托管选项选项:选择在非 Google 网站上托管结果,然后选择 iframe
5. 指定搜索结果详情:输入你第一步创建页面的页面的地址。如我的:http://fairyfish.net/search/
6. 然后用搜索框代码替换你原来的 WordPress 搜索框代码。你需要根据你自己的 WordPress 搜索框的样式对这段代码做下修改,以适合你的主题。
7. 编辑你第一步创建的页面,把搜索结果代码复制到该页面。你也需要对该段代码做些调整。主要是修改下 googleSearchFrameWidth = 600;,把 600 修改成适合你主体的宽度。
8. 然后到达外观 tab 页面,在该页定义搜索框样式和搜索结果配色方案。
9. 如果你要整合 Google Adsense 到这个结果中来,还可以使用到赚钱这个 tab 页面,绑定你 Google Adsense 账号。
就这么多,如果还不明白,我也没有办法。
46 条评论 添加你的评论
Trackbacks/Pingbacks
- 用上了Google自定义搜索 - 晓阳的散乱时光|关注互联网,关注媒体,关注热点事件
- wordpress完善(二) : : 轶侠的网上小窝
- 在WordPress中使用Google自定义搜索引擎 - 汤姆の世界
- 网站更新 - 不开玩笑
- Apple Theme (apple4us) 2.7 - 肚破惊天 - 真理和美女都是赤裸裸的。
- 软件博客联合搜索:善用佳软+小众软件+电脑玩物 | 善用佳软 免费软件博客
- 为何以及如何整合Google搜索到WP博客 at Becomin' Charles
- WordPress 主题: Clean home | 桃园水榭





1. ysuiyun | April 29, 2008 at 1:20 pm | #
沙发,哈~
2. 54geek | April 29, 2008 at 1:22 pm | #
沙发
3. 54geek | April 29, 2008 at 1:22 pm | #
原来不是的,慢了一步,呵呵
4. 雀巢 | April 29, 2008 at 2:14 pm | #
学习了
5. summer | April 29, 2008 at 2:43 pm | #
我用google ads加了一个搜索框:)
其实google的检索比本地快~
6. adam | April 29, 2008 at 3:05 pm | #
不够详细 呵呵 比如要实现搜索结果显示在http://fairyfish.net/search/ 要把search.php放在根目录
7. Denis | April 29, 2008 at 3:56 pm | #
是 http://fairyfish.net/search/ 不是 http://fairyfish.net/search.php
这是 WordPress 的一个静态页面。
8. Admin9 | April 29, 2008 at 3:39 pm | #
刚从chinaz看到。过来看看。
9. Denis | April 29, 2008 at 3:58 pm | #
chinaz是什么?
10. sytao | April 29, 2008 at 4:18 pm | #
站长站
11. Denis | April 29, 2008 at 4:20 pm | #
看了下,全部是…..
12. Crazy Loong | April 29, 2008 at 5:38 pm | #
你的版权声明又被忽略了
13. Denis | April 29, 2008 at 5:47 pm | #
防不胜防!垃圾网站太多了!
14. Admin9 | April 29, 2008 at 11:42 pm | #
忽略版权的事,他们经常干。。
15. 摩摩诘 | April 30, 2008 at 6:08 pm | #
中国站长站是个垃圾,到处采集,不加原链接….
16. 乐乐猪 | April 29, 2008 at 3:42 pm | #
试验中
17. Meinv | April 29, 2008 at 4:01 pm | #
学习了
马上回去试验….
18. Leo | April 29, 2008 at 4:56 pm | #
笨鱼,WordPress 2.5已经搜索页面了。
19. Denis | April 29, 2008 at 5:22 pm | #
我假装他不行。
20. 摩摩诘 | April 29, 2008 at 10:57 pm | #
嘿嘿,终于出现了,可惜我的主机挂了,不能试验…
21. 9NPC | April 30, 2008 at 12:12 am | #
我的站也是用GOOGLE自定義搜索。此前也寫過一篇幅介紹,給大家當個附加參考
http://www.9npc.com/2008/03/google-cse.html
22. tomdbtel | April 30, 2008 at 9:20 am | #
这个教程写得好
23. 阳阳 | May 1, 2008 at 11:54 am | #
我用的是blogbus的博客,搜索用的是google adsense里的搜索框,感觉也不错!
24. K | May 2, 2008 at 10:39 am | #
感谢水煮鱼!我弄好了
.
25. 54geek | May 6, 2008 at 2:26 am | #
一个控制搜索结果页宽度的CSS修改代码:http://www.eryi.org/blog/post/google-co-op-cse-width.html
26. 轶侠 | May 10, 2008 at 9:04 pm | #
谢谢哦,学会一招,真好
不过下面的那个smile我就是用不了,明明表情都显示了,可是点上去就报错
firefox报错说
错误: tinyMCE.selectedInstance has no properties
源文件:http://www.e-xia.com/e-xia/blog/index.php?ak_action=wp_grins_js
行:40
哎~~~~
27. 轶侠 | May 11, 2008 at 8:03 am | #
为啥我在2.51装了报错呢,能看到icon,一点就报错。
看了一下你的页面源代码,就只有很少的一段javascript,是不是改过了
28. 轶侠 | May 11, 2008 at 8:36 am | #
郁闷,又发错地方
29. jc0100 | May 21, 2008 at 4:39 pm | #
猪大,就是强啊!!!!好方法
30. Young | July 20, 2008 at 10:47 pm | #
这个玩意之前没有注意,现在发现很有用。如果花钱买一个Goolge自定义搜素,最少也得100美金/年。
31. Tom | August 12, 2008 at 6:22 am | #
用 wp_list_pages() 这个函数输出页面的,你可以使用 exclude 这个参数把刚才创建的页面剔除出去。
在我的(header.php)下有个,但不知exclude这个参数怎么加近去啊?新建的search页面ID是11。请详细解释一下好吗?希望您的回复,谢谢!
32. Tom | August 12, 2008 at 6:28 am | #
用 wp_list_pages() 这个函数输出页面的,你可以使用 exclude 这个参数把刚才创建的页面剔除出去。
在我的(header.php)下有个wp_list_pages(’title_li=&depth=1′);,但不知exclude这个参数怎么加近去才能剔除search啊?新建的search页面ID是11。请详细解释一下好吗?希望您的回复,谢谢!
33. Denis | August 12, 2008 at 10:38 am | #
wp_list_pages(’title_li=&depth=1&exclude=1′);
34. Tom | August 12, 2008 at 3:47 pm | #
把wp_list_pages(’title_li=&depth=1&exclude=1′);改成wp_list_pages(’title_li=&depth=1&exclude=11′);
就OK了。谢谢您!
35. 鸟类网 | November 8, 2008 at 4:26 pm | #
介绍的很好,我的网站已经很好的整合了Google自定义搜索,包括搜索框样式都可以进行了美化。
36. tsman | November 18, 2008 at 4:41 pm | #
终于用上了,可是怎么让搜索框靠右边呀!麻烦看一下
37. logtee | December 30, 2008 at 4:08 pm | #
exclude 这个参数怎么用呢?
38. Andy | March 29, 2009 at 1:57 pm | #
我的自定义搜索只能搜索首页,不知道怎么回事