Skip to content

Instantly share code, notes, and snippets.

@ethanhinson
Created December 6, 2013 22:50
Show Gist options
  • Save ethanhinson/7833505 to your computer and use it in GitHub Desktop.
Save ethanhinson/7833505 to your computer and use it in GitHub Desktop.
Attaching JS to every page's footer in with WordPress best practices.
<?php
/**
* All code should live in functions.php of the active theme
*/
function attach_js() { ?>
<script type="text/javascript">
document.write('ALL MY JS CAN GO IN BETWEEN THESE SCRIPT TAGS'); //Test script only, not required
</script>
<?php }
// Adds an action the footer of every page. In this case, just add some JS
add_action('wp_footer', 'attach_js');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment