1

Well , I'm trying the next loop to make work DFP in an Infinite Scroll.

I thought that if I change the name of the Slot I could get the banner shown, so I tried this:

<!-- DFP Controller -->
  <script>
   <?php if(is_home()) : ?>
   googletag.cmd.push(function() {
     gptadslots[0]= googletag.defineSlot('/94102516/home_960x90_a', [[960,90]],'960x90_a').addService(googletag.pubads());
     gptadslots[1]= googletag.defineSlot('/94102516/home_300x250', [[300,250]],'300x250').addService(googletag.pubads());
     gptadslots[2]= googletag.defineSlot('/94102516/home_960x90_b', [[960,90]],'960x90_b').addService(googletag.pubads());
     gptadslots[3]= googletag.defineSlot('/94102516/home_960x90_c', [[960,90]],'960x90_c').addService(googletag.pubads());

     googletag.pubads().enableSingleRequest();
     googletag.pubads().collapseEmptyDivs();
     googletag.pubads().enableAsyncRendering();
     googletag.enableServices();
   });
 <?php elseif(is_category()) : ?>
 googletag.cmd.push(function() {

   gptadslots[0]= googletag.defineSlot('/94102516/<?php adCat(); ?>_960x90', [[960,90]],'960x90').addService(googletag.pubads());
   gptadslots[1]= googletag.defineSlot('/94102516/<?php adCat(); ?>_300x250', [[300,250]],'300x250').addService(googletag.pubads());

   googletag.pubads().enableSingleRequest();
   googletag.pubads().collapseEmptyDivs();
   googletag.pubads().enableAsyncRendering();
   googletag.enableServices();
 });

<?php elseif(is_single()) : ?>
 googletag.cmd.push(function() {

  gptadslots[0]= googletag.defineSlot('/9410/<?php adCat(); ?>_960x90', [[960,90]],'960x90').addService(googletag.pubads());
  gptadslots[1]= googletag.defineSlot('/9410/<?php adCat(); ?>_300x250', [[300,250]],'300x250').addService(googletag.pubads());
  // gptadslots[2]= googletag.defineSlot('/94102516/notas_300x600', [[300,600]],'300x600n').addService(googletag.pubads());

  googletag.pubads().enableSingleRequest();
  googletag.pubads().collapseEmptyDivs();
  googletag.pubads().enableAsyncRendering();
  googletag.enableServices();
});
<?php endif; ?>

</script>
<!-- End DFP Controller -->

And , in the loop I'm trying this:

<section class="sixth">
  <?php
       //--- Sixth Featured
  $featured_6 = array(
   'posts_per_page' => 3,
   'offset' => 7
   );

  $f6 = new WP_Query( $featured_6 );

  if (  $f6->have_posts() ) :
    $count = 0;
  while (  $f6->have_posts() ) :  $f6->the_post();
  $count++;
  if ($count == 2) :
    ?>

  <article data-number="<?php echo $count; ?>">
    <!-- /941025/home_300x250_<?php echo $count; ?> -->
    <figure id="300x250_<?php echo $count; ?>" class="iHolder lazyload" style="width:300px;">
      <script>
       googletag.cmd.push(function() {
        googletag.display('300x250');    
      });
    </script>
  </figure>
</article>

<?php else : ?>

  <article>
    <figure class="iHolder">
      <a href="<?php the_permalink();?>">
        <?php the_post_thumbnail("dreams-1200x800", array( 'class'  => "lazyload"));?>
      </a>
    </figure>

    <div class="desc" style="background:#13254b;">
      <h3><a href="<?php the_permalink();?>"><?php the_title(); ?></a></h3>
    </div>
  </article>

  <?php
  endif;
  endwhile;
  endif;
  ?>

But, the thing is that is not working , obviously because the call is not getting the loop $counter, anyone , have a better idea??

thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.