wp_enqueue_script根本没有加载JS

时间:2017-09-05 12:36:20

标签: php wordpress wordpress-theming

已经构建了一个在一个域上运行和测试的Wordpress主题,但是,在将主题安装到另一个域时,我的wp_enqueue_script根本没有显示<script>,而<styles>正在显示在脑海中。

添加到functions.php的代码是

function core_styles_scripts() {
wp_enqueue_style( 'pace-css', get_template_directory_uri() . '/assets/plugins/pace/pace-theme-flash.css');
wp_enqueue_style( 'bootstrap-css', get_template_directory_uri() . '/assets/plugins/bootstrap/css/bootstrap.min.css');
wp_enqueue_style( 'fontawesome-css', get_template_directory_uri() . '/assets/plugins/font-awesome/css/font-awesome.css');
wp_enqueue_style( 'scrollbar-css', get_template_directory_uri() . '/assets/plugins/jquery-scrollbar/jquery.scrollbar.css');
wp_enqueue_style( 'select-css', get_template_directory_uri() . '/assets/plugins/select2/css/select2.min.css');
wp_enqueue_style( 'switchery-css', get_template_directory_uri() . '/assets/plugins/switchery/css/switchery.min.css');
wp_enqueue_style( 'pages-icons-css', get_template_directory_uri() . '/pages/css/pages-icons.css');
wp_enqueue_style( 'theme-light-css', get_template_directory_uri() . '/pages/css/themes/light.css');
wp_enqueue_style( 'theme-custom-css', get_template_directory_uri() . '/pages/css/themes/custom.css');
wp_enqueue_style( 'google-fonts',  '//fonts.googleapis.com/css?family=Playfair+Display:400,700,900|Open+Sans:400,600');



wp_enqueue_script( 'feather-icons-js', get_template_directory_uri() . '/assets/plugins/feather-icons/feather.min.js', array(), '1.0.0', true );
wp_enqueue_script( 'pace-js', get_template_directory_uri() . '/assets/plugins/pace/pace.min.js', array(), '1.0.0', true );
wp_enqueue_script( 'jquery-js', get_template_directory_uri() . '/assets/plugins/jquery/jquery-1.11.1.min.js', array('jquery'), '1.0.0', true );
wp_enqueue_script( 'mondernizr-js', get_template_directory_uri() . '/assets/plugins/modernizr.custom.js', array('jquery'), '1.0.0', true );
wp_enqueue_script( 'jquery-ui-js', get_template_directory_uri() . '/assets/plugins/jquery-ui/jquery-ui.min.js', array(), '1.0.0', true );
wp_enqueue_script( 'tether-js', get_template_directory_uri() . '/assets/plugins/tether/js/tether.min.js', array(), '1.0.0', true );
wp_enqueue_script( 'bootstrap-js', get_template_directory_uri() . '/assets/plugins/bootstrap/js/bootstrap.min.js', array(), '1.0.0', true );
wp_enqueue_script( 'jquery-easy-js', get_template_directory_uri() . '/assets/plugins/jquery/jquery-easy.js', array('jquery'), '1.0.0', true );
wp_enqueue_script( 'jquery-unveil-js', get_template_directory_uri() . '/assets/plugins/jquery-unveil/jquery.unveil.min.js', array('jquery'), '1.0.0', true );
wp_enqueue_script( 'jquery-bez-js', get_template_directory_uri() . '/assets/plugins/jquery-bez/jquery.bez.min.js', array('jquery'), '1.0.0', true );
wp_enqueue_script( 'jquery-ioslist-js', get_template_directory_uri() . '/assets/plugins/jquery-ios-list/jquery.ioslist.min.js', array('jquery'), '1.0.0', true );
wp_enqueue_script( 'imagesloaded-js', get_template_directory_uri() . '/assets/plugins/imagesloaded/imagesloaded.pkgd.min.js', array(), '1.0.0', true );
wp_enqueue_script( 'jquery-actual-js', get_template_directory_uri() . '/assets/plugins/jquery-actual/jquery.actual.min.js', array('jquery'), '1.0.0', true );
wp_enqueue_script( 'jquery-scrollbar-js', get_template_directory_uri() . '/assets/plugins/jquery-scrollbar/jquery.scrollbar.min.js', array('jquery'), '1.0.0', true );
wp_enqueue_script( 'jquery-sticky-tabs-js', get_template_directory_uri() . '/assets/plugins/jquery-sticky-tabs/jquery.stickytabs.js', array('jquery'), '1.0.0', true );
wp_enqueue_script( 'bootstrap-tabs', get_template_directory_uri() . '/assets/plugins/bootstrap-collapse/bootstrap-tabcollapse.js', array(), '1.0.0', true );
wp_enqueue_script( 'select2', get_template_directory_uri() . '/assets/plugins/select2/js/select2.full.min.js', array(), '1.0.0', true );
wp_enqueue_script( 'classie', get_template_directory_uri() . '/assets/plugins/classie/classie.js', array(), '1.0.0', true );
wp_enqueue_script( 'nav-tabs-url', get_template_directory_uri() . '/assets/js/scripts.js', array(), '1.0.0', true );
wp_enqueue_script( 'pages-js', get_template_directory_uri() . '/pages/js/pages.js', array(), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'core_styles_scripts' );

我无法找到上述的错误,但也许其他人可以。重新提一下 - 在一个域中,<scripts>已添加到<footer><style>已添加到<head>(正确),另一个域(新安装) )它将<style>保留在<head>中,但<script>根本没有加载。我已经尝试了两个安装零插件和只有相同问题的主题。我试过删除所有其他功能。我尝试过HTTPS和HTTP。

感谢任何帮助。我保证这很简单,我遗漏了一些明显的东西。此外,在调试或firebug中都没有任何错误。

1 个答案:

答案 0 :(得分:0)

使用::
add_action('wp_footer','core_styles_scripts');
而不是
add_action('wp_enqueue_scripts','core_styles_scripts');