免插件在WordPress上添加广告的方法
2012-09-22 12:56
260 查看
免插件在WordPress上添加广告的方法
现在越来越多的人都做了自己的独立博客,并且博客流量也不少,那么也就不能白白浪费这些流量,故而我们可以在不影响用户体验上适当的加入一些广告,让流量转换为收入。下面我就向大家简单的介绍免插件WordPress上添加广告的方法。
为WordPress博客添加广告一般有两种方法:一是安装广告插件,二是直接添加代码实现。本着插件越少越好的原则,我强烈推荐第二种方法,也就是给主题相关文件直接添加代码。
下面的一段代码可以帮助你实现不用插件也可以给博客文章中插入环绕效果的广告。
首先你要对wordpress的主题有点了解,你先在你当前使用的博客主题文件夹中找到single.php(文章页面)文件,用记事本打开文件,找到这段代码 <?php the_content(‘Read more…’); ?>在这段代码之前插入以下代码
<div style=”float:right; padding-bottom:10px;padding-top:10px;”>
广告代码放这里
</div>
同样道理,如果你想给文章的底部也加上广告,你可以继续往下找到这段代码 <?php comments_template(); ?> 将以下代码放到这段代码的前面
<div style=”float:right; padding-bottom:10px;padding-top:10px;”>
广告代码放这里
</div>
如果你想在博客的首页第一篇文章中和下面放置google adsense的广告,你可以在当前使用的主题文件夹下面找到index.php(首页页面)文件,用记事本打开,找到如下代码 <?php the_content(); ?>
在这段代码前面插入代码
<?php if ($wp_query->current_post == 0) : ?>
<div style=”float:right; padding-bottom:10px;padding-top:10px;”>
广告代码</div>
<?php endif; ?>
在<?php the_content(); ?>这段代码的后面插入
<?php if ($wp_query->current_post == 0) : ?>
<div style=”padding-top:10px;text-align:center;”>
广告代码</div>
<?php endif; ?>
这样做的优点是可以避免使用插件,但是缺点是如果你更换主题,你就要从新更改一次。
http://www.chenguangblog.com/archives/wordpress-add-advertising
进入你的Blog后台–>外观–>编辑 –> 打开 文章页面模板 (single.php)
或者直接下载 文章页面模板 (single.php) 文件,然后打开
找到这段代码 “php the_content” 在这段代码之前插入以下代码:
<div style=”float:right; padding-bottom:10px;padding-top:10px;”>
google adsense 广告代码
</div>
实现的关键是float:right
二、Wordpress日志内容页面底部添加广告
继续往下找到这段代码 php comments_template(); 将以下代码放到这段代码的前面
<div style=”float:right; padding-bottom:10px;padding-top:10px;”>
google adsense 广告代码
</div>
三、在Wordpress日志内容顶部加广告
打开single.php,找到php the_content();
在 php the_content(); 上面加上广告代码即可:
<div style=”padding-bottom:10px;padding-top:10px;”>
广告代码
</div>
<?php the_content(); ?>
四、Blog的首页第一篇文章下面放置google adsense的广告
可以在当前使用的主题文件夹下面找到index.php文件,打开
找到如下代码 php the_content();
在这段代码前面插入代码
<?php if ($wp_query->current_post == 0) : ?>
<div style=”float:right; padding-bottom:10px;padding-top:10px;”>
google adsense 广告代码
</div>
<?php endif; ?>
在php the_content(); 这段代码的后面插入
<?php if ($wp_query->current_post == 0) : ?>
<div style=”padding-top:10px;text-align:center;”>
336*280Adsense代码
</div>
<?php endif; ?>
这些是一些常用的在wordpress中添加Google Adsense代码的技巧
http://linhun.com/1211.html
现在越来越多的人都做了自己的独立博客,并且博客流量也不少,那么也就不能白白浪费这些流量,故而我们可以在不影响用户体验上适当的加入一些广告,让流量转换为收入。下面我就向大家简单的介绍免插件WordPress上添加广告的方法。
为WordPress博客添加广告一般有两种方法:一是安装广告插件,二是直接添加代码实现。本着插件越少越好的原则,我强烈推荐第二种方法,也就是给主题相关文件直接添加代码。
下面的一段代码可以帮助你实现不用插件也可以给博客文章中插入环绕效果的广告。
首先你要对wordpress的主题有点了解,你先在你当前使用的博客主题文件夹中找到single.php(文章页面)文件,用记事本打开文件,找到这段代码 <?php the_content(‘Read more…’); ?>在这段代码之前插入以下代码
<div style=”float:right; padding-bottom:10px;padding-top:10px;”>
广告代码放这里
</div>
同样道理,如果你想给文章的底部也加上广告,你可以继续往下找到这段代码 <?php comments_template(); ?> 将以下代码放到这段代码的前面
<div style=”float:right; padding-bottom:10px;padding-top:10px;”>
广告代码放这里
</div>
如果你想在博客的首页第一篇文章中和下面放置google adsense的广告,你可以在当前使用的主题文件夹下面找到index.php(首页页面)文件,用记事本打开,找到如下代码 <?php the_content(); ?>
在这段代码前面插入代码
<?php if ($wp_query->current_post == 0) : ?>
<div style=”float:right; padding-bottom:10px;padding-top:10px;”>
广告代码</div>
<?php endif; ?>
在<?php the_content(); ?>这段代码的后面插入
<?php if ($wp_query->current_post == 0) : ?>
<div style=”padding-top:10px;text-align:center;”>
广告代码</div>
<?php endif; ?>
这样做的优点是可以避免使用插件,但是缺点是如果你更换主题,你就要从新更改一次。
http://www.chenguangblog.com/archives/wordpress-add-advertising
如何在wordpress中添加优化Google Adsense广告代码
一、Wordpress日志内容页面添加环绕广告进入你的Blog后台–>外观–>编辑 –> 打开 文章页面模板 (single.php)
或者直接下载 文章页面模板 (single.php) 文件,然后打开
找到这段代码 “php the_content” 在这段代码之前插入以下代码:
<div style=”float:right; padding-bottom:10px;padding-top:10px;”>
google adsense 广告代码
</div>
实现的关键是float:right
二、Wordpress日志内容页面底部添加广告
继续往下找到这段代码 php comments_template(); 将以下代码放到这段代码的前面
<div style=”float:right; padding-bottom:10px;padding-top:10px;”>
google adsense 广告代码
</div>
三、在Wordpress日志内容顶部加广告
打开single.php,找到php the_content();
在 php the_content(); 上面加上广告代码即可:
<div style=”padding-bottom:10px;padding-top:10px;”>
广告代码
</div>
<?php the_content(); ?>
四、Blog的首页第一篇文章下面放置google adsense的广告
可以在当前使用的主题文件夹下面找到index.php文件,打开
找到如下代码 php the_content();
在这段代码前面插入代码
<?php if ($wp_query->current_post == 0) : ?>
<div style=”float:right; padding-bottom:10px;padding-top:10px;”>
google adsense 广告代码
</div>
<?php endif; ?>
在php the_content(); 这段代码的后面插入
<?php if ($wp_query->current_post == 0) : ?>
<div style=”padding-top:10px;text-align:center;”>
336*280Adsense代码
</div>
<?php endif; ?>
这些是一些常用的在wordpress中添加Google Adsense代码的技巧
http://linhun.com/1211.html
相关文章推荐
- WordPress广告放置三大方法和技巧(含插件)
- wordpress最简单添加后台插件的方法
- Unity3D的Android游戏添加google广告的插件及使用方法
- WordPress插件制作教程(三): 添加菜单的方法
- wordpress中不使用插件添加文章浏览数及评论数的方法。
- iOS中///快速添加方法注释插件
- WordPress升级主题、插件的时候提示连接FTP的解决方法
- 不用插件给wordpress添加关键词和描述
- WordPress中添加自定义评论表情包的方法
- 免插件为WordPress文章中标签添加内链
- Breadcrumb NavXT – WordPress页面导航”面包屑”插件使用方法教程
- eclipse下添加viplugin插件的方法
- WordPress中使主题支持小工具以及添加插件启用函数
- WordPress代码高亮插件CodeColorer正确使用方法
- WordPress Audio Player 非插件方式使用方法
- 本地wordpress加载速度缓慢的解决方法和安装插件
- eclipse插件Maven添加依赖查询无结果的解决方法(Select Dependency doesn't work)
- WordPress如何添加广告位?wordpress常见的几种广告位的添加方法
- 改善用户体验之wordpress添加图片弹出层效果 (插件 FancyBox)
- 织梦/DedeCMS v5.5首页栏目添加广告的方法