How to put inline javascript in the footer of your page with WordPress

You can do this by adding this code to your template file. This will add a hook. Your javascript code will now be placed in the footer of your page (or where the wp_footer() function is called).

<?php
function footer_script(){ ?>
<script>
jQuery(document).ready(function(){
    //put your js code here
})
</script>
<?php }

add_action('wp_footer', 'footer_script'); ?>

 

Geef een reactie

Vul je gegevens in of klik op een icoon om in te loggen.

WordPress.com logo

Je reageert onder je WordPress.com account. Log uit /  Bijwerken )

Facebook foto

Je reageert onder je Facebook account. Log uit /  Bijwerken )

Verbinden met %s