Free Webinar

Replay Now Available!
How to Build a WordPress Plugin
Watch Today!

Webinar Replays

Miss the live version?
Watch the Video Replay Now!
View Today!

Hi! I'm Dustin

My Goal is to Inspire You to
Do Amazing Things with WordPress
Learn More about Me
158 – WordPress Free vs WordPress Self-Hosted
 
Play
Announcements
Listener Feedback

Robert – How to add custom Javascript to a WordPress theme?

  • Download code to computer
  • Add downloaded Javascript to theme folder (I like to put this in a JS folder, inside the theme folder)
  • Open up functions.php file in theme file. If this file doesn’t exist, create one
  • Add the following code to enqueue the script. This will add the javascript properly and not conflict with WordPress core javascript files

  • <?php wp_enqueue_script( accordian, get_template_directory_uri() . '/js/accordian.js', jquery, false, true ); ?>

Here is the code from the codex

<?php wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); ?>

Tony asks, how can I integrate my WordPress site with Amazon S3

WordPress.com versus WordPress.org

WordPress.org

WordPress is the open source software that powers millions of websites around the world, including this one. It is open source software where anyone can use, contribute or modify the code.

WordPress.com

WordPress.com is a commercial website where you can host a free site with some limitations or pay for small upgrades. WordPress.com uses the exact same softwarea as WordPress.org, but you don’t have to keep your software up-to date or backed up.

WordPress.org vs. WordPress.com

Call To Action

– Watch some of the sessions from WordShesh 2

Published on: 11 Dec | Podcast | 2 responses| Tags:

Subscribe and Never Miss an Episode

               
2 comments
Nate Finch
Nate Finch

Hey Dustin! Thanks for the episode. 

Just curious, to avoid adding to the functions.php file, could you instead create a plugin for "custom scripts" to run this extra java script and any others that you may want to add? I feel like I've heard that method is also a good one:-). Just curious. Have a good one!

dhartzler10
dhartzler10 moderator

@Nate Finch indeed. since the javascript is theme dependent, it's okay to have it in the functions.php. If this would be something you'd always want on your site, then I'd recommend creating a custom functionality plugin.