2017-11-04 3 views
0

私は、私は次のことをやっている 、WordPressののfunctions.phpファイルで私のカスタムJavaScriptコードをエンキューしようとしているjqueryに依存するjavascriptをen-queueする方法はありますか?

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はです。これに関するいかなる助けも高く評価されます。ありがとう!

答えて

1

プラグインで追加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'); 
関連する問題