将 Bootstrap 放入我的 WordPress 主题中——无法将 Javascript 文件放入
Getting Bootstrap into my WordPress theme -- can't get Javascript file in
我一直在关注如何将 Bootstrap 添加到 WordPress 网站(例如 https://digitalfellows.commons.gc.cuny.edu/2013/11/18/learn-bootstrap-part-2-adding-bootstrap-to-wordpress/)的在线食谱说明,但我不知道自己做错了什么.我进入了 bootstrap.min.css
而不是 bootstrap.min.js
。知道为什么会这样吗?
我的 functions.php
包括
function register_and_enqueue_shit ( ) {
wp_register_script( 'bootstrap-js', get_template_directory_uri() . '/bootstrap-3.3.4-dist/js/bootstrap.min.js', array('jquery'), NULL, true );
wp_register_style( 'bootstrap-css', get_template_directory_uri() . '/bootstrap-3.3.4-dist/css/bootstrap.min.css', false, NULL, 'all' );
wp_register_style( 'fontawesome-css', get_template_directory_uri() . '/font-awesome-4.3.0/css/font-awesome.min.css', false, NULL, 'all' );
wp_enqueue_script( 'bootstrap-js' );
wp_enqueue_style( 'bootstrap-css' );
wp_enqueue_style( 'fontawesome-css');
}
add_action( 'admin_head', 'register_and_enqueue' );
add_action( 'wp_enqueue_scripts', 'register_and_enqueue_shit' );
我的主题文件结构是
bootstrap-3.3.4-dist
css
boostrap.min.css
.
.
fonts
js
boostrap.min.js
.
.
font-awesome-4.3.0
.
.
footer.php
functions.php
.
.
wp_enqueue_script(
'bootstrap-js',
get_template_directory_uri() . '/bootstrap-3.3.4-dist/js/bootstrap.min.js'
array('jquery')
);
去掉wp_register_script
然后试试上面的方法
我一直在关注如何将 Bootstrap 添加到 WordPress 网站(例如 https://digitalfellows.commons.gc.cuny.edu/2013/11/18/learn-bootstrap-part-2-adding-bootstrap-to-wordpress/)的在线食谱说明,但我不知道自己做错了什么.我进入了 bootstrap.min.css
而不是 bootstrap.min.js
。知道为什么会这样吗?
我的 functions.php
包括
function register_and_enqueue_shit ( ) {
wp_register_script( 'bootstrap-js', get_template_directory_uri() . '/bootstrap-3.3.4-dist/js/bootstrap.min.js', array('jquery'), NULL, true );
wp_register_style( 'bootstrap-css', get_template_directory_uri() . '/bootstrap-3.3.4-dist/css/bootstrap.min.css', false, NULL, 'all' );
wp_register_style( 'fontawesome-css', get_template_directory_uri() . '/font-awesome-4.3.0/css/font-awesome.min.css', false, NULL, 'all' );
wp_enqueue_script( 'bootstrap-js' );
wp_enqueue_style( 'bootstrap-css' );
wp_enqueue_style( 'fontawesome-css');
}
add_action( 'admin_head', 'register_and_enqueue' );
add_action( 'wp_enqueue_scripts', 'register_and_enqueue_shit' );
我的主题文件结构是
bootstrap-3.3.4-dist
css
boostrap.min.css
.
.
fonts
js
boostrap.min.js
.
.
font-awesome-4.3.0
.
.
footer.php
functions.php
.
.
wp_enqueue_script(
'bootstrap-js',
get_template_directory_uri() . '/bootstrap-3.3.4-dist/js/bootstrap.min.js'
array('jquery')
);
去掉wp_register_script
然后试试上面的方法