我喜欢在WordPress网站中插入adsense目录、归档、标签和搜索页面列表。以下是我能在网上找到的最接近的解决方案:
<?php $postcounter = 1;
if (have_posts()) : ?>
<?php while (have_posts()) : $postcounter = $postcounter + 1;
the_post(); ?>
<?php if(4 == $postcounter)
{ echo ' <div id="adsbetween">
<center> YOUR_ADSENSE_CODE </center>
</div> ' ;
} ?>我需要帮助我在以下主题中应用相同的内容:
if (($cat_layout == 'masonry-3') || ($cat_layout == 'masonry-2')) {
echo '<div class="module-masonry-wrapper clear-fix">';
echo '<div class="masonry-content-container">';
while (have_posts()): the_post();
echo kid_masonry_render(get_the_ID());
endwhile;
echo '</div></div>';下面是另一个例子:
echo '<div class="classic-blog-content-container">';
while (have_posts()): the_post();
echo kid_classic_blog_render(get_the_ID(), 35);
endwhile;
echo '</div>';代码应该在第四个清单之后添加ADSENSE_CODE。
有什么帮助吗?
发布于 2017-03-18 08:25:01
这应该注入adsense并让循环继续(我认为这就是您想要的)。
if($cat_layout=='masonry-3' || $cat_layout=='masonry-2'){
$postcounter=1;
echo '<div class="module-masonry-wrapper clear-fix">';
echo '<div class="masonry-content-container">';
while(have_posts()){
if($postcounter==4){
echo '<div id="adsbetween"><center>YOUR_ADSENSE_CODE</center></div>';
}
the_post();
echo kid_masonry_render(get_the_ID());
++$postcounter;
}
echo '</div>';
echo '</div>';
}额外的案件:
$postcounter=1;
echo '<div class="classic-blog-content-container">';
while(have_posts()){
if($postcounter==4){
echo '<div id="adsbetween"><center>YOUR_ADSENSE_CODE</center></div>';
}
the_post();
echo kid_classic_blog_render(get_the_ID(),35);
++$postcounter;
}
echo '</div>';' https://stackoverflow.com/questions/42871469
复制相似问题