I need to run this javascript code on a specific wordpress page.
The code inserted in the "Head", now works on all pages.
What code should I insert?
<script src="https://example.com/code.js" type="text/javascript"></script>
I am not a developer, but a newbie.
2
Answers
Please use the code below. Add this code to your functions.php file:
Note:
is_page(123): Replace 123 with the ID of the page where you want to run this script.
is_page(‘home’): Replace home with the slug of the page where you want to run this script.
Because you’re new to save a meltdown. Rather than editing functions.php (1 typo and your whole instance goes down). I suggest you either install one of the many code plugins that allow you to target a specific page. Or just add a code module to the content of the page and put your script in there.