How to Install Google cse into wordpress Blog

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

发表评论

电子邮件地址不会被公开。 必填项已用*标注