php - How to load JavaScript in WordPress -
I need to know if this is the correct way to load javascript using functions.php
< Pre> function wd_load_script () {wp_deregister_script ('jquery'); Wp_register_script ('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js', False, '1.10.2', true); Wp_register_script ('cufon-yui', get_template_directory_uri (). '/js/cufin-yui.js', 'jquery'); Wp_register_script ('cufon-aller', get_template_directory_uri (). '/js/cufon-aller.js', 'jquery'); Wp_register_script ('script', get_template_directory_uri (). '/js/script.js', 'jquery'); Wp_register_script ('coin-slider.min', get_template_directory_uri (). '/js/coin-slider.min.js', 'jquery'); Wp_enqueue_script ('jquery'); Wp_enqueue_script ('cufon-yui'); Wp_enqueue_script ('cufon-aller'); Wp_enqueue_script ('script'); Wp_enqueue_script ('coin-slider.min'); } Add_action ('wp_enqueue_scripts', 'wd_load_script'); Yes, this code is the correct way to load javascript in java, though the third parameter should be an array wp_register_script
'jquery' instead of array ('jquery'). >. For example:
wp_register_script ('Cufon-yui', get_template_directory_uri (). '/js/cufin-yui.js', 'jquery'); From
to:
wp_register_script ('cufon-yui', get_template_directory_uri (). '/js/cufin-yui.js', array (' jquery '));
Comments
Post a Comment