Add external js to one page

I’ve been digging around for a while and I can’t seem find what I need to do. I need to add an external js to one page and one page only, specifically…
<script src="https://embed.twitch.tv/embed/v1.js"></script>

I realize I can’t really do that in the page custom js section unless there’s something obvious I’m missing, and there probably is. Can any one help point me in the right direction?

Hello there,

Thank you for writing in :slight_smile:

The first thing you will need to do is find the post ID, to do this - please review the following article: https://theme.co/apex/forum/t/setup-how-to-locate-post-ids/59 (the same process is to find a page ID, simply go to Pages --> All Pages instead).

If you then want to show a script to your custom page that has the ID of 123, you can use the following code in your child theme’s functions.php file:

add_action( 'wp_footer', 'custom_page_script', 10 );

function custom_page_script(){
   if ( is_page(123) ) {
      echo 'add your script here';
   }
}

Instead of echo 'add your script here'; you will need to use echo '<script src="https://embed.twitch.tv/embed/v1.js"></script>';

I hope this helps.

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