05/13/2016   Comments Off on Add inline javascript to WordPress correctly

View all snippets

Add to functions.php file. Name the add_action whatever. You can also have the script load in the footer by changing wp_head to wp_footer.

// Add JS to Head
 function spd_add_cart_link() { // break out of php ?>
   // javascripts here
 <?php } // break back into php

Source link