Using scripts in the topic

AI-generated summary

Gonerdot wants to implement JavaScript in specific topics to add an ad unit from their ad network. pfaffman advises against allowing users to add JavaScript to topics for security reasons, but suggests using a theme component for this purpose.

Gonerdot explains that they need to install the JavaScript code in specific places, not just the Body or Footer, and that the advertising plugin’s House Ads feature does not support JavaScript.

pfaffman recommends checking out the Plugin outlet locations theme component and theme development tutorials for guidance on inserting custom content. However, Gonerdot finds it difficult to understand and implement.

pfaffman provides additional resources, including a tutorial on adding custom content to the homepage, but Gonerdot decides to postpone the task due to its complexity.

How can i implement the use of javascript in topics?

In a theme component.

But if you want users to be able to put javascript in topics, it’s a bad idea and you can.

Can you say more about what it is you’re trying to accomplish?

I want to add javascript code to specific topics.
This code calls an ad unit from the ad network I’m working with.
Therefore, it is necessary to install it in specific places, and not just through a component, since there the choice is only between Body and Footer.

I tried using House Ads from the advertising plugin, but it doesn’t support JS

Look at the topics about how to develop themes. Also check out the Plugin outlet locations theme component to see where you can insert stuff.

Looks interesting, but my knowledge is not enough to understand how to use it :sweat_smile:

Can you tell me how to insert the necessary code here?

Maybe this will help: Add custom content that only appears on your homepage

But you’ll need to have a look at the theme development tutorial.

It’s too difficult for me. Looks like we’ll have to put this off for later for now. :smiling_face_with_tear: