wordpress添加广告(网络整理)

VPSok
2010-10-22 / 0 评论 / 1,614 阅读 / 正在检测是否收录...
腾讯云,腾讯云服务器,腾讯云促销

今晚闲来无聊,突然想试试添加广告来玩。
其实,最早的时候好VPS有个google广告的,不过被K了…首先,我来说说我这个主题prower V2我这里右侧的广告植入吧。找到rsidebar.php文件,在你想要放置广告的位置加入:<li><h2>赞助广告</h2>,后面加上广告代码(注意,为了这个主题的整体美观,建议选250*250广告)
下面我们来说说文章页面的广告的加入方法:
一、Wordpress日志内容页面添加环绕广告
博客主题文件夹下找到single.php文件,然后打开
找到这段代码 “php the_content” 在这段代码之前插入以下代码:

<div style=”float:left; padding-bottom:10px;padding-top:10px;”>
  广告代码
</div>

实现的关键是float:left  它是指漂浮到左边,如果你喜欢在右边的话,改为 right
请注意代码的双引号,如果没有效果出来,就检查下双引号!
二、Wordpress日志内容页面底部添加广告
广告代码加在<?php the_content(); ?>之后:

<?php the_content(); ?>
<div style=”padding:3px 0″>
广告代码
</div>

 
三、在Wordpress日志内容顶部加广告
打开single.php,找到php the_content();在 php the_content(); 上面加上广告代码即可:

<div style=”padding:3px 0″>
广告代码
</div>
<?php the_content(); ?>

四、博客的首页第一篇文章下面放置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;”>
336*280广告代码
</div>
<?php endif; ?>

呵呵,我估计指望靠这个赚钱是有点难度滴,不过我还是弄了个来玩玩,好看嘛~~


香港/美国/国内高速VPS

35

评论 (0)

取消