额外补充1
WordPress的分类页、Search页,Tag页等输出的文章列表时,如果想在中间位置(比如第5个文章后面)出现,可以用下面的代码:


<?php if ($wp_query->current_post == 4) : ?>  
    <div> 广告代码 </div>  
<?php endif;  ?>  
<?php if ($wp_query->found_posts < 5 and $wp_query->current_post == ($wp_query->found_posts - 1)): ?>  
    <div> 广告代码 </div>  
<?php endif; ?>

$current_post 属性,必须用在 Loop 里面,表示当前显示的文章索引值;它是以 0 为起始值,如果想要在第5个文章后面,$wp_query->current_post 等于 4 即可。

$found_posts 属性,表示按 $wp_query 匹配的文章总数。

上面的代码只能放在 Loop 里面,比如 if (have_posts()) : while (have_posts()) : the_post(); 后面,表示广告代码将在文章列表的第5个文章后面出现,如果列表匹配出来的文章总数不到5个,就在列表的最后位置出现广告代码。

额外补充2
当然您也可以使用另一个方法~ 只需要在发布文章时切换成文本,然后加入如下代码即可:


<script type="text/javascript">document.location = "http://www.ilxtx.com"</script>

注意替换网址为你想跳转的链接。可用于老文章失效,跳转到新文章哦~