在WordPress首页文章列表中插入广告代码
打开模板文件index.php,找到:
<?php if (have_posts()) : ?>
在这行代码的上面加入:
<?php $count = 1; ?>
找到:
<div class=“entry”>
在这行代码的下面加入:
<?php if ($count == 1) : ?>
广告代码
<?php endif; $count++; ?>
注:要改变广告在列表中所处的位置,改变$count == 1中的数字即可,例如$count == 2表示将在第二个帖子下显示广告。
|