wp_enqueue_script()를 통해 두 개의 스크립트를로드하려고합니다. 함수를 만들었지 만 첫 번째로드는 두 번째로드가 아닙니다. 다음은 코드입니다.wp_enqueue_script()가 여러 스크립트를로드하지 않습니다.
//Load my own jQuery
function fix_noconflict() {
wp_deregister_script('jquery');
wp_register_script('jquery' , 'http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js');}
add_action('wp_enqueue_scripts' , 'fix_noconflict');
//This two functions follow the same
function mauricio_bootstrap_script_jquery() {
//Includes bootstrap jQuery
wp_register_script('custom-script', get_template_directory_uri().'/mauricio_bootstrap/js/bootstrap.js', array('jquery'));
//This enqueus the script
wp_enqueue_script('custom-script');
}
// Adds the new bootstrap function to the wp_enqueue_scripts
add_action('wp_enqueue_scripts', 'mauricio_bootstrap_script_jquery');
function mauricio_bootstrap_script_carousel() {
wp_register_script('myscript', get_template_directory_uri().'/mauricio_bootstrap/js/bootstrap-carousel.js', array('jquery'));
wp_enqueue_script('myscript');
}
add_action('wp_enqueue_script', 'mauricio_bootstrap_script_carousel');
내 머리 속에 wp_head()가 있습니다. 그리고 bootstrap.js가 포함 된 첫 번째 함수가로드됩니다.
감사합니다,
M이 제공하는 워드 프레스 포럼에서
이것은 올바른 답변입니다. 깨끗하고, 쉽고, 한 곳에서 모두. –
이것은 또한 완벽하게 작동합니다! 감사 – mauricioSanchez