- This topic has 13 replies, 2 voices, and was last updated 3 years, 8 months ago by Tom.
-
AuthorPosts
-
August 21, 2020 at 11:31 am #1413089Anil
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.
August 21, 2020 at 3:17 pm #1413272TomLead DeveloperLead DeveloperHi there,
Try making your ad an
<article>
element instead of<div>
.Let me know 🙂
August 25, 2020 at 1:24 pm #1418038AnilThanks 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 …
August 25, 2020 at 2:04 pm #1418071AnilHi 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.
August 25, 2020 at 2:52 pm #1418107TomLead DeveloperLead DeveloperHi 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?August 25, 2020 at 5:46 pm #1418211Anilyes, it shows ads on page 2 and after 10 posts same issue….
August 26, 2020 at 9:31 am #1419261TomLead DeveloperLead DeveloperHow are you adding the code in the first place?
August 26, 2020 at 10:31 am #1419367Anilwith ad inserter
August 26, 2020 at 11:00 am #1419411AnilHi 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….
August 26, 2020 at 2:08 pm #1419594TomLead DeveloperLead DeveloperHi there,
The theme doesn’t do any cleaning like that – it simply initiates infinite scroll and allows it to take over.
It could be that infinite scroll itself is stripping the javascript – I haven’t tested it.
Perhaps this is related?: https://wordpress.org/support/topic/insert-responsive-adsense-on-infine-scroll-pages/
August 26, 2020 at 8:44 pm #1419837AnilHi 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….
August 27, 2020 at 9:46 am #1420773TomLead DeveloperLead DeveloperThe 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?
August 27, 2020 at 12:47 pm #1420965AnilDear 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….August 27, 2020 at 2:23 pm #1421051TomLead DeveloperLead DeveloperSeems 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 thewp_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.
-
AuthorPosts
- You must be logged in to reply to this topic.