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
32 responses to “Add Javascript To Specific WordPress Pages Using Functions.php”
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 馃檪
awesome thanks!!
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.
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?
What background music is that please?
Hi your videos are awesome. Can i add data.json,bodymovin,index.html,new.js to wordpress
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
HELLO, How do you remove ……This is where you can add new products to your store. on Oceanwp theme
Awesome 馃槈
thank you so much
Cool. How to add an additional js file?
Im trying to use m3u8 file/s in my website but doesnt load on the player can you help please.
how can we add a script at spcific location in a wordpress page.plzz reply
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?
the same way for jquery too?????
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煤
Great tutorial! Thanks!
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);
}());
is there a way i can apply it to my whole site? – without breaking anything
Thank you for being awesome! and posting this.
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.
This was great – thank you!
//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"
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)
Thanks. I fould it useful to upload my html files to word press!!!!!!!!!!!!! Awesome
Pls how can I see my PhP codes for using an elementor template so that I can add a code?
转讜讚讛 专讘讛 住专讟讜谉 诪注讜诇讛
good one i would be hapy if you explained rest two parameters of enque script function
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?
I love You!
https://wplearninglab.com/add-javascript-to-specific-wordpress-pages (404 not found)
The page isnt loading with the code I would of used it