Javascript 谷歌adsense没有';不会出现在php循环中

Javascript 谷歌adsense没有';不会出现在php循环中,javascript,php,wordpress,adsense,Javascript,Php,Wordpress,Adsense,我正试图在我的wordpress网站上每5篇帖子之间插入谷歌广告,并带有无限滚动条 这是我用来在每5篇帖子之间添加谷歌广告的代码 <? if ( have_posts() ) : $count = 0; while ( have_posts() ) : the_post(); //before if (($count>1) && ($count%5 == 0) ){ ?> <!-- AD_HP_RC-2 --

我正试图在我的wordpress网站上每5篇帖子之间插入谷歌广告,并带有无限滚动条

这是我用来在每5篇帖子之间添加谷歌广告的代码

    <?  

if ( have_posts() ) : $count = 0; while ( have_posts() ) : the_post();

    //before 

    if (($count>1) && ($count%5 == 0) ){ 
    ?>

<!-- AD_HP_RC-2 -->
<div id="adsbetween">
<div id='div-gpt-ad-xxxx-0' style="width:300px; height:450px; display:inline-block;       float:right;">
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-xxxx-0'); });
</script>
</div>
</div>
    <?

    }

    $count++;

googletag.cmd.push(函数(){googletag.display('div-gpt-ad-xxxx-0');});

您应该为您的id提供唯一标识符。像这样的

   <? if ( have_posts() ) : $count = 0; while ( have_posts() ) : the_post();

    //before 

    if (($count>1) && ($count%5 == 0) ){ 
    ?>

<!-- AD_HP_RC-2 -->
<div id="adsbetween">
<div id='div-gpt-ad-xxxx-<?php echo $count; ?>' style="width:300px; height:450px; display:inline-block;       float:right;">
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-xxxx-<?php echo $count; ?>'); });
</script>
</div>
</div>
    <?

    }

    $count++;

  • 你也在你的标题中加载广告吗?据我所知的DFPAPI,你在内容中包含的每个广告都必须在网站标题中提及。在这种情况下,它们将具有唯一标识符
  • 您是通过DFP交付AdSense标签还是使用AdSense Fallback for DFP?在第一种情况下,max-3-ads规则仍然适用。在第二种情况下,我也不会指望总是有3个以上的广告

  • 而且尽量不要使用短的php标记