• Resolved tbalcie

    (@tbalcie)


    Hello,

    supernice tool is this!

    I wanted to add the AdInserter shortcode to a texfield for this Advent plugin, using this shortcode: [adinserter block=”1″]. But it seems that it is not working correctly.

    What can we do to make it work?

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Verdant Studio

    (@verdantstudio)

    Hi @tbalcie, thank you for reaching out.

    Could you provide more details about the issue you’re experiencing? I’ve installed the Ad Inserter plugin and can confirm that the shortcode is being converted to output. However, I’m currently testing without a real ad.

    Please note that the calendar’s content is dynamically loaded on request. If your code relies on events like DOMContentLoaded, it may not trigger as expected because the page has already finished loading by the time the calendar content appears.

    Thread Starter tbalcie

    (@tbalcie)

    Hello,

    you can see it on this page: https://geocachen.be/hebbes-woodie/

    If you open the first day (Dag 1), then you see that the ad isn’t loaded, but you can see a part of the code. What can I do about that?

    Plugin Author Verdant Studio

    (@verdantstudio)

    Currently, the content behind every door is loaded on request to verify if someone is allowed to access a specific day. This is to prevent people from peaking at the page source to see the rewards.

    In your code you have the script tag loading the adsbygoogle.js file, but it won’t be initialised because the page has already finished loading before the content is there. So what you could do is:

    Is add the following to your functions.php:

    function add_google_adsense(){
    ?>
    <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <script>
    const days = document.querySelectorAll('.superac-day');
    days.forEach(el => el.addEventListener('click', event => {
    setTimeout(function() {
    return (adsbygoogle = window.adsbygoogle || []).push({});
    }, 1000);
    }));
    </script>
    <?php
    }
    add_action( 'wp_footer', 'add_google_adsense' );

    You would then only keep the HTML part <ins ...></ins> inside Adinserter.

    I’ll see if this is something I can improve on in a future version of the plugin.

    Thread Starter tbalcie

    (@tbalcie)

    Hi,

    I added the code to the functions.php. It looks like it is working, but why is a bit of the adsense code displayed? Normally you should only see an ad, know this code is also triggered/displayed:

    style=”display:block”
    data-ad-client=”ca-pub-xxxxxxxxxxxxx”
    data-ad-slot=”xxxxxxxxxxxx”
    data-ad-format=”auto”
    data-full-width-responsive=”true”>

    Plugin Author Verdant Studio

    (@verdantstudio)

    From what I can tell the AdInserter still contains the <script> tags, you should only leave the <ins>…</ins> tags there. Because you are now loading the script tags via your functions.php.

    Thread Starter tbalcie

    (@tbalcie)

    Still the same if I delete the <script> tags

    Only the ins tags are left.

    Plugin Author Verdant Studio

    (@verdantstudio)

    Seems the output is still coming from the AdInserter. Perhaps try:

    1. Resave the page with the calendar (it shouldn’t matter but for testing purposes)
    2. Check any caching plugins
    3. Double check if really saved the AdInserter and the output is really not there anymore, maybe add different text to make sure

    If it is still not working, please reach out via the contact form and send me a screenshot of the Adinserters content.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.