Menu Close

How to add a JavaScript to the footer that requires jQuery?

Codeamend

Code Snippet to add a JavaScript to the footer in function.php

function codeamendscript() {
?>
<script type="text/javascript">
  //Add script here...
</script>
<?php
}
add_action( 'wp_footer', 'codeamendscript' );

function codeamendscript_jquery() {
    wp_enqueue_script( 'jquery' );
}
add_action( 'wp_head' , 'codeamendscript_jquery' ); 
Posted in JavaScript, jQuery, WordPress

You can also read...