2014-09-05 46 views
0

我想插入谷歌广告每5个职位在我的WordPress的网站与无限滚动。谷歌AdSense不会出现在一个PHP循环

这是我使用的每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++; 

第一个广告加载罚款之间,但是从第二个广告,它只是空的空间,添加谷歌的广告代码。

我在我的网站中使用dfp,因此在这种情况下允许超过3个Google广告。

这是网站网址:http://bluehandwebdesign.com/dev/hk/

能否请你帮我在这?

回答

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++; 
+0

也。尽量不要使用短php标签 – 2014-09-05 15:40:20

0
  1. 东西你也加载在你的头的广告吗?就我所知的dfp api而言,您在内容中包含的每个广告也必须在网站标题中提及。在这种情况下,他们将拥有唯一的标识符。
  2. 您是通过DFP广告管理系统投放AdSense代码还是为AdSense广告管理系统使用AdSense回退?在第一种情况下,max-3-ads规则仍然适用。在第二种情况下,我也不会总是有超过3个广告。