飞龙博客

妙法莲华经

How to Install Google cse into wordpress Blog

feilong.org 修订于2010-05-17 11:01:52 428 次浏览

google-custom-search-engine is better than the wordpress search itself,and more you can make a little money of it perhaps.How to install goole cse into wordpress blog?here feilong write down the easiest steps.The post url is http://feilong.org/Google-cse-into-wordpress edited by feilong on May 17th 2010

First Step.creat new template.

1.paste the code below

<?php
/*
Template Name: cse
*/
?>
<?php get_header(); ?>
<!--feilong tips,
here you place your google cse code.then seach the line:
draw('cse')

next add code as below:

var match = location.search.match(/q=([^&]*)(&|$)/);
if(match && match[1]){
var search = decodeURIComponent(match[1]);
customSearchControl.execute(search);
}
}, true);

-->
<?php get_footer(); ?>

2.save the file as mycse.php.And upload it under your theme.

Second Step.Creat new page.

1.the title:whatever as you like
2.the post slug:search
3.click html editor,input code below,
<div id="cse"> loading....</div>
4.select the cse template you created at the first step.
5.publish the page.an eaxmple,http://feilong.org/search

Three Step.change the searchform.php
1.open the theme template searchform.php
2.clear the old code,or keep it temporary
2.add html code as below,
<form action="/search"  id="searchbox">
<input type="text" name="q" id="input_search" />
<input type="submit" value="Search" />
</form>

Last Step.test and enjoy!

Chinge edition:http://feilong.org/google-cse-into-blog

更新网址:https://feilong.org/google-cse-into-wordpress
最初发布:20100517 11:01:52 feilong.org 于广州

加入收藏夹,查看更方便。

所在分类: 日记

新作:

旧文: