2017-11-04 7 views
0

나는, 어떤 이유로, 사용자 정의 스크립트가 페이지에로드되지 않아요, 나는 다음을 수행하고 , 워드 프레스 'functions.php 파일에 자바 스크립트 코드 내 사용자 정의를 대기열에jquery에 종속성이있는 자바 스크립트를 대기열에 넣는 방법은 무엇입니까?

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');