Wordpress 如何将依赖jquery的javascript排队?
我试图将我的自定义javascript代码放入WordPress的functions.php文件中, 我在做下面的事情Wordpress 如何将依赖jquery的javascript排队?,wordpress,wordpress-theming,Wordpress,Wordpress Theming,我试图将我的自定义javascript代码放入WordPress的functions.php文件中, 我在做下面的事情 function background_animation_script() { wp_register_script('background_animation', plugins_url('/assets/js/jquery.backgroundPosition.js', __FILE__),array('jquery'),'1.0', true); } func
function background_animation_script() {
wp_register_script('background_animation', plugins_url('/assets/js/jquery.backgroundPosition.js', __FILE__),array('jquery'),'1.0', true);
}
function hero_animation_script() {
wp_register_script('hero_animation', plugins_url('/assets/js/background-animation.js', __FILE__), array('jquery','background_animation_script'), '1.0', true);
}
function custom_scripts() {
wp_enqueue_script('jquery');
wp_enqueue_script('background_animation_script');
wp_enqueue_script('hero_animation_script');
}
add_action('wp_enqueue_scripts', 'custom_scripts');
但是,由于某些原因,定制脚本没有加载到页面上,而jquery是。非常感谢您在这方面的任何帮助。谢谢 使用以下函数在插件中添加jquery
function custom_scripts() {
wp_enqueue_script( 'background_animation_script', plugins_url('/assets/js/jquery.backgroundPosition.js', __FILE__),array('jquery'),'1.0', true);
wp_enqueue_script( 'hero_animation', plugins_url('/assets/js/background-animation.js', __FILE__), array('jquery'), '1.0', true);
}
add_action('wp_enqueue_scripts', 'custom_scripts');