wp_enqueue_script()没有加载多个脚本

mau*_*hez 4 wordpress

我试图通过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' );
Run Code Online (Sandbox Code Playgroud)

只是为了记录我在标题中有wp_head().正如我所说它加载包含bootstrap.js的第一个函数.

谢谢,

中号

Pab*_*eco 9

为什么不尝试将所有函数放在main函数中,像这样?

function wpEnqueueScripts(){
    // Adds the new bootstrap function to the wp_enqueue_scripts
    wp_register_script('custom-script', get_template_directory_uri() . '/mauricio_bootstrap/js/bootstrap.js', array('jquery'));
    wp_enqueue_script('custom-script');

    // Adds the new bootstrap function to the wp_enqueue_scripts
    wp_register_script('myscript', get_template_directory_uri() . '/mauricio_bootstrap/js/bootstrap-carousel.js', array('jquery'));
    wp_enqueue_script('myscript');
}    

add_action('wp_enqueue_scripts', 'wpEnqueueScripts');
Run Code Online (Sandbox Code Playgroud)