越来越多的博客在他们的博客上挂了点击广告来获得收入,三两饭也不例外,其中 Google AdSense 又是主流的广告选择。相信在日志中插入 Google AdSense 广告代码已经不是什么难事,但是要在日志的任意位置插入 Google AdSense 代码呢?你也能够办得到么?
呵呵,如果办不到请往下看:
首先,你需要在 founction.php 文件中插入如下的代码:
function showads() {
return '<script type="text/javascript"><!--
google_ad_client = "pub-3637220125174754";
google_ad_slot = "4668915978";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
';
}
add_shortcode('adsense', 'showads');
return '<script type="text/javascript"><!--
google_ad_client = "pub-3637220125174754";
google_ad_slot = "4668915978";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
';
}
add_shortcode('adsense', 'showads');
保存文件,现在插入广告代码的功能已经植入到你的主题中,你要做的就是在写日志的时候插入 [adsense] 代码来调用 Google AdSense 广告代码就 OK 了。


red October 09,2009 02:34 PM#
老大,我用你这个方法,怎么函数总也加不进去呢!
我用的是 wp 2.8.4
是在 wp-include 目录里面的 founctions.php 里面添加代码吗?
回复
» 广告酷 - 广告从小做起 » 皓辰吧 - Hc8.Net.Ru March 21,2009 11:59 AM#
[...] Google AdSense [...]
hiswing December 19,2008 10:09 PM#
这招真帅。赞一个。
回复