Grab Your Free 17-Point WordPress Pre-Launch PDF Checklist: http://vid.io/xqRL
Add Javascript To Specific WordPress Pages https://youtu.be/Fw6VDOZYqrM
Link to blog post with code: https://wplearninglab.com/add-javascript-specific-wordpress-pages/
Link to Conditional Tags in WordPress codex: https://codex.wordpress.org/Conditional_Tags
If you want to add JavaScript to a specific page in WordPress this is how you do it without using a plugin. You do have edit the functions.php file, so do that carefully. Backup your existing functions file if you need to. Then just use the code from the blog post to add JavaScript to any page on your WordPress site.
Stop brute force attacks before they happen with this workshop: https://wplearninglab.com/brute-force-eliminator-workshop
Grab your free 17-Point WordPress Pre-Launch PDF Checklist: http://vid.io/xqRL
Download your exclusive 10-Point WP Security Checklist: http://bit.ly/10point-wordpress-hardening-checklist
Subscribe to this awesome channel here: http://www.youtube.com/subscription_center?add_user=wplearninglab
Original source
Santiago Zuluaga G
This video is AMAZING! It worked! I tried so many things and this one was the magic one. Thank you a TON. Subbed for sure 🙂
Trickybats
awesome thanks!!
El umbral del socavón
Thank you!!. 05/24/2019 and I found at the end how to add JS, me, a simple designer with desire to learn programming. I give thanks to life that there are people like you.
EasyTechs
Thanks so much for the detailed explanation, quick question: Can you add multiple scripts to the same header, e.g. AdSense and Google analytics? and how do you separate them to be sure they are well laid out for google?
SaintMTE
What background music is that please?
Svenska nyheter
Hi your videos are awesome. Can i add data.json,bodymovin,index.html,new.js to wordpress
Adrian Rainbow
Sorry, I have redone my comment 🙂 Thank you for your help, and I have got it all working well. But, i have an issue with wordpress removing my code after changing screens to the visual. I used your method in the video for the specific page, but any ideas how to stop making wordpress change my code when flicking to the visual? here is the JS i used instead of I am here alert: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_copy_clipboard
Noah Peter
HELLO, How do you remove ……This is where you can add new products to your store. on Oceanwp theme
Lavigne s Blood Stain Jun
Awesome 😉
Goromu DomToSeng
thank you so much
davesguitarplanet
Cool. How to add an additional js file?
Sidonio Soares
Im trying to use m3u8 file/s in my website but doesnt load on the player can you help please.
ANKIT SHEORAN
how can we add a script at spcific location in a wordpress page.plzz reply
Elizabeth Bucher
I bought a plug in that is jquery, I am not a coder but I want to use this plug in with elementor page buidler. It is a slide show plug in. How can I do this?
Marsha Brightly
the same way for jquery too?????
Miguel Alexander Macedo Zegarra
hi Bjorn, thanks for the video…I coded this: https://code.sololearn.com/WTy88e9XfMHM/#html (is public) this code has html, css and javascript as you can see, but how can i do to include it in wordpress? just with this tutorial or what change should I do?. Thank you very much from Perú
tosh wilcox
Great tutorial! Thanks!
Rachana devi Subedi
I pasted the code below into my website's template just before the </BODY> tag but still not working. Please help
var pubID = '45215CL40786';
(function(d, t) {
var s = document.createElement('script');s.type = 'text/javascript';
s.async = true;s.src = (document.location.protocol == 'https:' ? 'https://cdn0.cuelinks.com/js/' : 'http://cdn0.cuelinks.com/js/'😉 + 'cuelinksv1.js';
document.getElementsByTagName('body')[0].appendChild(s);
}());
lahannahlou
is there a way i can apply it to my whole site? – without breaking anything
Adam Altamirano
Thank you for being awesome! and posting this.
James Summers
Thanks for this, it works! I had change the false to true and had to find a code to add multiple page ids to one specific javascript, but the base code/method that you showed works.
J Jackson
This was great – thank you!
Professional Cipher
//Script code for Copy to ClipBoard
function copyDivToClipboard() {
var range = document.getSelection().getRangeAt(0);
range.selectNode(document.getElementById("a"));
window.getSelection().addRange(range);
document.execCommand("copy")
}
add_action( 'wp_enqueue_scripts', 'copyDivToClipboard' );
It is showing me "syntax error, unexpected T_VAR"
Ronny Gunnarsson
This is exactly what I want to do. Run a javascript on one specific page. I did as instructed. To test I first only created one java file with the alert command you showed. The alert does not show up but I can see in the source that the java file is loaded. I am running WordPress. Is there any other setting I should change to enable the execution of the java file? (The alert should show up here: http://science-network.tv/signs-test-mcnemars-test/ and the java file is currently pairwise_test.js)
A A
Thanks. I fould it useful to upload my html files to word press!!!!!!!!!!!!! Awesome
ENOCH YOUNG
Pls how can I see my PhP codes for using an elementor template so that I can add a code?
ינון אלבז
תודה רבה סרטון מעולה
UI Monk
good one i would be hapy if you explained rest two parameters of enque script function
Franbert Peña Peralta
I want to add html code to a specific post but I think the 'load_js_assets' action won't work with html code… what can I do?
Anjelica Dixon
I love You!
Santosh Biswal
https://wplearninglab.com/add-javascript-to-specific-wordpress-pages (404 not found)
adam
The page isnt loading with the code I would of used it