Site logo

Archived topic

infinite scroll

13 replies · Started by Anil on August 21, 2020

Viewing posts 1–14 of 14

Hi

I have inserted a text box after every 2 posts on home page archive.

Please guide how to add this custom text box after every 2 posts if I use infinite scroll...

Regards.

Hi there,

Try making your ad an <article> element instead of <div>.

Let me know :)

Thanks Tom, it is working with some caveat.

Ad Inserter Plugin OR GPP removes
(adsbygoogle = window.adsbygoogle || []).push({});

from

<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

in posts after initial 10 posts or first page....

Any solution ...

Hi Tom,

I posted this at plugin support (removing-part-of-ad-unit), and @spacetime replied:

Hello,

the plugin does not remove any code.

Your theme loads subsequent pages via ajax request, for example
https://h___k.com/page/2/
https://h___k.com/page/3/

The pages contains inserted codes as configured in Ad Inserter.

However, when the posts from the loaded pages are inserted into the homepage, the adsense javascript code seems to be removed. very likely the theme “cleans” the loaded code before adding it to the homepage.

I suggesto to contact theme authors.

Hi there,

The theme itself doesn't do any cleaning/sanitizing. It simply requests the <article> elements from the next page and loads them inline using Infinite Scroll: https://infinite-scroll.com/

I don't believe Infinite Scroll doesn't any cleaning, either.

If you navigate to /page/2 on your site, does the code exist?

yes, it shows ads on page 2 and after 10 posts same issue....

How are you adding the code in the first place?

with ad inserter

Hi Tom Plugin author replied

However, when the posts from the loaded pages are inserted into the homepage, the adsense javascript code seems to be removed. very likely the theme “cleans” the loaded code before adding it to the homepage.

Please check....

Hi Tom

Initially ads were not inserted on scroll as I was using div to add.
After your suggestion I convereted div to article, it started loading but without script.
It shows complete ad code but without script showing only <script></script>.

It means adinserter started pulling ad-code.

Either Plugin or Theme removing script code.

1. Plugin author says plugin not removing / cleaning code.

2. Theme author says theme not removing / cleaning code.

3. Theme using third party code to implement scroll, and theme author unable to say about "infinite scroll" stripping the code or not.

4. Link you guided not providing any solution.

Any further suggestion....

The code isn't being stripped out, it's still there: https://www.screencast.com/t/6k2bjaBE0

The ads simply aren't displaying. I'm not an Adsense expert, so I'm not sure why that would be happening. Too many ads displaying on one page, maybe?

Dear Tom,

Code is there, yes, but it is stripping this part from the code

(adsbygoogle = window.adsbygoogle || []).push({});

and empty opening and closing syntax of
<script></script>

so why this part (adsbygoogle = window.adsbygoogle || []).push({}); is stripped....

Seems to be common with AJAX loading: https://wordpress.org/support/topic/google-adsense-not-supporting-on-ajax-infinite/

You could try adding some javascript to your site:

1. Create a Hook Element:
2. Select the wp_footer hook.
3. Add your content:

<script>
    var $container = jQuery( '#main article' ).first().parent();

    $container.on( 'append.infiniteScroll', function() {
        (adsbygoogle = window.adsbygoogle || []).push({})
    } );
</script>

4. Set your Display Rules.

Again - not an Adsense expert, but it's worth a shot.

This archived topic is closed to new replies.