• Wednesday , 3 June 2020

Add Javascript To Specific WordPress Pages Using Functions.php

Code Canyon



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

3d Ocean

Related Posts

32 Comments

  1. Santiago Zuluaga G
    July 8, 2019 at 13:46

    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 🙂

  2. Trickybats
    July 8, 2019 at 13:46

    awesome thanks!!

  3. El umbral del socavón
    July 8, 2019 at 13:46

    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.

  4. EasyTechs
    July 8, 2019 at 13:46

    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?

  5. SaintMTE
    July 8, 2019 at 13:46

    What background music is that please?

  6. Svenska nyheter
    July 8, 2019 at 13:46

    Hi your videos are awesome. Can i add data.json,bodymovin,index.html,new.js to wordpress

  7. Adrian Rainbow
    July 8, 2019 at 13:46

    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

  8. Noah Peter
    July 8, 2019 at 13:46

    HELLO, How do you remove ……This is where you can add new products to your store. on Oceanwp theme

  9. Lavigne s Blood Stain Jun
    July 8, 2019 at 13:46

    Awesome 😉

  10. Goromu DomToSeng
    July 8, 2019 at 13:46

    thank you so much

  11. davesguitarplanet
    July 8, 2019 at 13:46

    Cool. How to add an additional js file?

  12. Sidonio Soares
    July 8, 2019 at 13:46

    Im trying to use m3u8 file/s in my website but doesnt load on the player can you help please.

  13. ANKIT SHEORAN
    July 8, 2019 at 13:46

    how can we add a script at spcific location in a wordpress page.plzz reply

  14. Elizabeth Bucher
    July 8, 2019 at 13:46

    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?

  15. Marsha Brightly
    July 8, 2019 at 13:46

    the same way for jquery too?????

  16. Miguel Alexander Macedo Zegarra
    July 8, 2019 at 13:46

    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ú

  17. tosh wilcox
    July 8, 2019 at 13:46

    Great tutorial! Thanks!

  18. Rachana devi Subedi
    July 8, 2019 at 13:46

    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/&#39; : 'http://cdn0.cuelinks.com/js/&#39😉 + 'cuelinksv1.js';

    document.getElementsByTagName('body')[0].appendChild(s);

    }());

  19. lahannahlou
    July 8, 2019 at 13:46

    is there a way i can apply it to my whole site? – without breaking anything

  20. Adam Altamirano
    July 8, 2019 at 13:46

    Thank you for being awesome! and posting this.

  21. James Summers
    July 8, 2019 at 13:46

    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.

  22. J Jackson
    July 8, 2019 at 13:46

    This was great – thank you!

  23. Professional Cipher
    July 8, 2019 at 13:46

    //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"

  24. Ronny Gunnarsson
    July 8, 2019 at 13:46

    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)

  25. A A
    July 8, 2019 at 13:46

    Thanks. I fould it useful to upload my html files to word press!!!!!!!!!!!!! Awesome

  26. ENOCH YOUNG
    July 8, 2019 at 13:46

    Pls how can I see my PhP codes for using an elementor template so that I can add a code?

  27. ינון אלבז
    July 8, 2019 at 13:46

    תודה רבה סרטון מעולה

  28. UI Monk
    July 8, 2019 at 13:46

    good one i would be hapy if you explained rest two parameters of enque script function

  29. Franbert Peña Peralta
    July 8, 2019 at 13:46

    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?

  30. Anjelica Dixon
    July 8, 2019 at 13:46

    I love You!

  31. adam
    July 8, 2019 at 13:46

    The page isnt loading with the code I would of used it

Leave A Comment

You must be logged in to post a comment.