简体   繁体   中英

Inserting google ads between posts in a wordpress site with infinite scroll

I am trying to insert google ads between every 5 posts in my wordpress site with infinite scroll.

This is the code I am using to add the google ads between every 5 posts

if ( have_posts() ) : $count = 0; while ( have_posts() ) : the_post();
    //before 
    if (($count>1) && ($count%5 == 0) ){ ?>
      <div>
        [adcode] 
      </div> 
   <? }
    $count++;

The code works for first sets of posts loaded but it does not work with infinite scroll. The infinite scroll loads the next set of posts without the google ad.

This is the site i am working with http://bluehandwebdesign.com/dev/hk/

This is the reference site http://terra.com/

Can you help?

Is far as I know: You are not allowed to do this. There is a maximum of 3 ads per page and you don't want your account suspened :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM