[PAID] - Trigger a javascript when new posts are loaded and House Ad-plugin adds a div

AI-generated summary

janbolmeson is trying to add JavaScript code to load ads in a specific div using the official ads plugin in Discourse. The code is not being executed when added to the house ad HTML. itsbhanusharma suggests trying to add the JavaScript code via a theme component, and offers further assistance via email if needed.

I am trying to add ads to my Discourse-forum and I am kind of stuck and I would need some help from you guys, if possible.

Background:

  • I am using the official adsplugin with the “house ads” setting to add a html-tag e.g <div id="rikatillsammans_desktop-panorama-1_c"></div> every 10th post. This works.

  • In order to fill that div with content - I would need to trigger a javascript such as:

    lwhb.cmd.push(function() {
        lwhb.loadAd({
            tagId: 'rikatillsammans_desktop-panorama-1_c',
        });
    });

But the problem is that I don’t know how to load it.

If I add it to the house-ad-function so it includes the code with the div, it does not seem to get executed. I.e. I cannot add the javascript to the house ad-html.

Possible?

Best regards,
Jan

1 Like

Have you tried to add it in a theme component? I would recommend you try it and if it still doesn’t work, I might be able to help you with the implementation. Drop me an email to bhanu@orng.co if you still need help.

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.