Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在wordpress中包含jquery、jquery ui_Jquery_Wordpress - Fatal编程技术网

如何在wordpress中包含jquery、jquery ui

如何在wordpress中包含jquery、jquery ui,jquery,wordpress,Jquery,Wordpress,如何在wordpess中包含jquery、jquery ui核心和。我得到一个错误“uncaughtypeerror:jQuery(…).uitop不是函数”。下面是一段代码: function magikCreta_load_jquery(){ wp_enqueue_script('jquery'); wp_enqueue_script('jquery-ui-core'); wp_enqueue_script('jquery-ui', 'https://ww

如何在wordpess中包含jquery、jquery ui核心和。我得到一个错误“uncaughtypeerror:jQuery(…).uitop不是函数”。下面是一段代码:

function magikCreta_load_jquery(){
      wp_enqueue_script('jquery');
      wp_enqueue_script('jquery-ui-core');
      wp_enqueue_script('jquery-ui', 'https://www.paytabs.com/theme/express_checkout/js/jquery-1.11.1.min.js', array('jquery-ui-core'));
    }

<?php echo '<script>
            jQuery(document).ready(function($){
                Paytabs("#express_checkout").expresscheckout({
});</script>';
函数magikCreta\u load\u jquery(){
wp_排队_脚本('jquery');
wp_排队_脚本('jquery-ui-core');
wp_排队_脚本('jquery-ui','https://www.paytabs.com/theme/express_checkout/js/jquery-1.11.1.min.js,数组('jquery-ui-core');
}

最好的方法是加载一个单独的文件

add_action('wp_enqueue_scripts', 'so13452_enqueue_scripts');
function so13452_enqueue_scripts() {
    // The array('jquery', 'jquery-ui-core') will force jquery and jquery-ui-core from core to be included
    wp_enqueue_script('name', get_stylesheet_directory_uri().'/file.js', array('jquery', 'jquery-ui-core'));

    // Only include jquery core
    wp_enqueue_script('jquery');

    // Jquery ui core
    wp_enqueue_script('jquery-ui-core');

}
您还可以将其添加到内联:

add_action('wp_head', 'so13453_enqueue_scripts');
function so13453_enqueue_scripts() {
    ?>
        <script>
            //
        </script>
     <?php
}
add_action('wp_head','so13453_enqueue_scripts');
函数so13453_排队_脚本(){
?>
//

请通读belwo代码,希望有帮助

add_action('wp_enqueue_scripts', 'my_enqueue_scripts');
function my_enqueue_scripts() 
 {
      //the array with jquery and jquery-ui-core are dependency for your file i.e my-custom.js 
    wp_enqueue_script('my-custom-js', get_stylesheet_directory_uri().'/my-custom.js', array('jquery', 'jquery-ui-core'));  
}
并将您的自定义代码放置到my custom.js

jQuery(document).ready(function($){
                Paytabs("#express_checkout").expresscheckout({
});

您意识到,
jquery-1.11.1.min.js
文件只是jquery,而不是jquery UI?加载第二个jquery会破坏任何以前加载的插件。这里的任何内容都不表示您正在加载一个插件脚本,该脚本将包含缺少的函数。是,此加载页脚中的my-custom.js,而不是初始化我的div