Ad Inserter has been very useful plugin for inserting various ads on our website. I am facing issue while inserting an Ad Unit on Post pages using Ad Inserter in Infinite Scroll. I am using Ad inserter to insert Google Ad Manager Ad Units on article pages, everything works fine except the ad unit does not show on next article while the infinite scroll active.
It is the same ad unit as in Normal Article which works absolutely fine but when it is called inside the next article of Infinite Scroll it just don’t show. I think it is due to having same Div id for both units as in First Article and in the next article of infinite scroll.
The solution can be changing the Ad Unit Div id Article dynamically. Can you help me achieve this and provide a solution to change div id dynamically. If you have some better idea which can work to resolve the problem please let me know.
Ad Unit Showing Ad in First Post

Same Ad Unit Not Showing Ad in Next Post in Infinite Scroll

The Ad Unit Code is:
<div id='div-ad-gpt-21619024108-1677680703-0'></div>
<script>
window.googletag = window.googletag || {cmd: []};
googletag.cmd.push(function() {
var aff_w = window.innerWidth;
if (aff_w >= 728) {
googletag.defineSlot('/21619024108/Nayag_Desktop_AP_MID1_728x90', [[728, 90]], 'div-ad-gpt-21619024108-1677680703-0').addService(googletag.pubads());
document.getElementById('div-ad-gpt-21619024108-1677680703-0').style.minHeight = 90+"px";
googletag.enableServices();
googletag.display('div-ad-gpt-21619024108-1677680703-0');
} else {
googletag.defineSlot('/21619024108/Nayag_Mobile_AP_MID1_336x280', [[300, 250], [336, 280]], 'div-ad-gpt-21619024108-1677680703-0').addService(googletag.pubads());
googletag.enableServices();
document.getElementById('div-ad-gpt-21619024108-1677680703-0').style.minHeight = 280+"px";
googletag.display('div-ad-gpt-21619024108-1677680703-0');
}
});
</script>
I am implementing it on test site you can check it here at
Thanks
- This topic was modified 8 hours, 11 minutes ago by .
- This topic was modified 7 hours, 25 minutes ago by . Reason: link moved to proper field
The page I need help with: [log in to see the link]