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 https://bluehandwebdesign.com/dev/hk/
This is the reference site https://terra.com/
Can you help?
- The topic ‘Inserting google ads between posts in a wordpress site with infinite scroll’ is closed to new replies.