在浏览文章列表时,用户已经习惯性会忽略掉第一篇文章前的广告,同样也会忽略掉文章列表结尾时的广告,大多数用户知道这个位置是常用的广告位,一般会一带而过。
为了将广告内内容搭配的更好,我们希望将广告放在指定篇文章的后面。
具体代码
<?php if (have_posts()) : ?>
<?php $count = 0; ?>
<?php while (have_posts()) : the_post(); ?>
<?php $count++; ?>
<?php if ($count == 2) {
?>
//在这里添加你的广告代码
<?php } ?>
<h2><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
注:$count == 2这里的2代笔广告位置,可以根据需要自行调整。
我比较喜欢这个模板
具体在那个配置文件里添加,我怎么加上不显示……
在index.php或archive.php中查找下面形式的代码
< ?php if (have_posts()) : ?>
将其替换成文章内容所述的代码。