2017-03-26 1 views
0

나는 parallaxjQuery 파일을로드하려고했지만이 인덱스 파일에 장전 그겁니다, 그것은 아무것도 실행되지 않습니다 트리거하지 ... 심지어 간단한 alert('test')자바 스크립트가로드하지만 워드 프레스

functions.php

function theme_scripts() { 
    wp_enqueue_style('theme-style', get_stylesheet_uri()); 
    wp_enqueue_style('theme-jquery', "https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"); 
    wp_enqueue_style('theme-parallax', get_template_directory_uri() . "/scripts/parallax.js"); 
    wp_enqueue_style('theme-mainjs', get_template_directory_uri() . "/scripts/main.js"); 

} 
add_action('wp_enqueue_scripts', 'theme_scripts'); 

예 main.js

(function($) { 
    $(function() { 
    alert('test') 
    }); 
})(jQuery); 
,174,

콘솔에서 보면 오류가 없습니다. 모든 것이 잘로드됩니다.

답변

2

wp_enqueue_style은 스크립트의 경우 CSS 파일에 사용되며 wp_enqueue_script이어야합니다.

https://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts

+0

덕분에, 그 바보 같은 실수였다! 그러나'wp_enqueue_script'로 변경하면 에러가 발생합니다 :'리소스를로드하지 못했습니다 : net :: ERR_EMPTY_RESPONSE' – Greg

+0

그리고 어떤 디렉토리에 액세스하려고 했습니까? 이제 경로와 관련된 문제 일뿐입니다. –

+0

이 세 가지 모두에서 실패합니다. 단지 URL 인 jQuery 링크 – Greg