我正在尝试使用functions.php
. 以下是我迄今为止所做的工作:
<?php
function blogroom() {
wp_enqueue_style(\'bootstrap\', get_stylesheet_directory_uri() . \'/assets/lib/bootstrap/dist/css/bootstrap.min.css\');
wp_enqueue_style(\'loaders\', get_stylesheet_directory_uri() . \'/assets/lib/loaders.css/loaders.min.css\');
wp_enqueue_style(\'iconsmind\', get_stylesheet_directory_uri() . \'/assets/lib/iconsmind/iconsmind.css\');
wp_enqueue_style(\'hamburgers\', get_stylesheet_directory_uri() . \'/assets/lib/hamburgers/dist/hamburgers.min.css\');
wp_enqueue_style(\'font-awesome-css\', get_stylesheet_directory_uri() . \'/assets/lib/font-awesome/css/font-awesome.min.css\');
wp_enqueue_style(\'theme-style\', get_stylesheet_directory_uri() . \'/assets/css/style.css\');
wp_enqueue_style(\'theme-style\', get_stylesheet_directory_uri() . \'/assets/css/custom.css\');
wp_register_script( \'bootstrap-js\', get_template_directory_uri() . \'/assets/lib/bootstrap/dist/js/bootstrap.min.js\');
wp_register_script( \'imageloaded\', get_template_directory_uri() . \'/assets/lib/imagesloaded/imagesloaded.pkgd.min.js\', array( \'bootstrap-js\' ) );
wp_register_script( \'tweenmax\', get_template_directory_uri() . \'/assets/lib/gsap/src/minified/TweenMax.min.js\', array(\'imageloaded\') );
wp_register_script( \'scroll-to-plugin\', get_template_directory_uri() . \'/assets/lib/gsap/src/minified/plugins/ScrollToPlugin.min.js\', array(\'tweenmax\') );
wp_register_script( \'customToEase\', get_template_directory_uri() . \'/assets/lib/CustomEase.min.js\', array(\'scroll-to-plugin\') );
wp_register_script( \'configJs\', get_template_directory_uri() . \'/assets/js/config.js\', array(\'customToEase\') );
wp_register_script( \'zanimation\', get_template_directory_uri() . \'/assets/js/zanimation.js\', array(\'configJs\') );
wp_register_script( \'corejs\', get_template_directory_uri() . \'/assets/js/core.js\', array(\'zanimation\') );
wp_register_script( \'mainjs\', get_template_directory_uri() . \'/assets/js/main.js\', array(\'corejs\') );
wp_enqueue_script( \'mainjs\' );
}
add_action( \'wp_enqueue_scripts\', \'blogroom\' );
?>
在这里,这只加载我的CSS文件,而不加载我的js文件。没有加载任何javascript文件。有人能帮忙吗?
SO网友:Akshat
您需要将脚本排队,排队时会自动注册,您可以通过以下方式替换代码段:,
<?php
function blogroom() {
wp_enqueue_style(\'bootstrap\', get_stylesheet_directory_uri() . \'/assets/lib/bootstrap/dist/css/bootstrap.min.css\');
wp_enqueue_style(\'loaders\', get_stylesheet_directory_uri() . \'/assets/lib/loaders.css/loaders.min.css\');
wp_enqueue_style(\'iconsmind\', get_stylesheet_directory_uri() . \'/assets/lib/iconsmind/iconsmind.css\');
wp_enqueue_style(\'hamburgers\', get_stylesheet_directory_uri() . \'/assets/lib/hamburgers/dist/hamburgers.min.css\');
wp_enqueue_style(\'font-awesome-css\', get_stylesheet_directory_uri() . \'/assets/lib/font-awesome/css/font-awesome.min.css\');
wp_enqueue_style(\'theme-style\', get_stylesheet_directory_uri() . \'/assets/css/style.css\');
wp_enqueue_style(\'theme-style\', get_stylesheet_directory_uri() . \'/assets/css/custom.css\');
wp_enqueue_script( \'bootstrap-js\', get_template_directory_uri() . \'/assets/lib/bootstrap/dist/js/bootstrap.min.js\');
wp_enqueue_script( \'imageloaded\', get_template_directory_uri() . \'/assets/lib/imagesloaded/imagesloaded.pkgd.min.js\', array( \'bootstrap-js\' ) );
wp_enqueue_script( \'tweenmax\', get_template_directory_uri() . \'/assets/lib/gsap/src/minified/TweenMax.min.js\', array(\'imageloaded\') );
wp_enqueue_script( \'scroll-to-plugin\', get_template_directory_uri() . \'/assets/lib/gsap/src/minified/plugins/ScrollToPlugin.min.js\', array(\'tweenmax\') );
wp_enqueue_script( \'customToEase\', get_template_directory_uri() . \'/assets/lib/CustomEase.min.js\', array(\'scroll-to-plugin\') );
wp_enqueue_script( \'configJs\', get_template_directory_uri() . \'/assets/js/config.js\', array(\'customToEase\') );
wp_enqueue_script( \'zanimation\', get_template_directory_uri() . \'/assets/js/zanimation.js\', array(\'configJs\') );
wp_enqueue_script( \'corejs\', get_template_directory_uri() . \'/assets/js/core.js\', array(\'zanimation\') );
wp_enqueue_script( \'mainjs\', get_template_directory_uri() . \'/assets/js/main.js\', array(\'corejs\') );
}
add_action( \'wp_enqueue_scripts\', \'blogroom\' );