戴尔 - 台式机

戴尔 - 笔记本

WordPress投放Google Adsense技巧

注册中国移动飞信

用过Google Adsense广告的朋友都知道,博客首页是我们放置广告的最佳位置,而嵌入文章内的广告的转换率最高,如果想在首页的每个标题下面加广告,选择“外观-〉主题编辑器->Main Index Template”,在〈?php if (have_posts())  〉的下面找到〈div class=”entry”〉,然后后面添加你的广告代码就可以了。

〈?php the_title(); ?〉
〈div class=”entry”〉
〈script type=”text/javascript”〉
google_ad_client = “pub-xxxxxxxxxxxxx”;
……

不过问题又来了。 主页上的文章通常都是5-10条,而Google广告要求在每一页显示的广告数量是有限的,通常放置不多于3条468×60的广告,如果按照上面的办法,每个文章标题下面都回出现广告,这是违反Google广告的要求的,小心被封帐号吧。

解决办法很简单,利用一个编程的小技巧,如下:

在〈?php while (have_posts()) : the_post(); ?〉上面加上:

〈?php
$xh=1;
?〉
在< div class="entry">下面加上

〈?php
if($xh==1 || $xh==2 || $xh==3){
?〉
〈script type=”text/javascript”〉〈!–
google_ad_client = “pub-xxxxxxxx”;
......你的Google广告代码
//–
〈/script〉
〈script type=”text/javascript”
src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”〉
〈/script〉
〈?php
}
$xh++;
?〉

这样广告就只会出现在前3篇文站里面了。 注意复制的时候请把< 和>改成英文符号<和>。


【注册Google adsense帐号】


编辑:Adsense 来源:Google广告联盟 时间:2007-07-13
|打印

站内搜索

栏目推荐:

本栏目热门: