admin管理员组文章数量:1291314
I want to add Bootstrap to a WordPress child theme that I edit using Elementor.
To do that, I used both CDN and bootstrap local files but neither worked. For the local files, I created a bootstrap folder in my child theme folder where I had only three folders : functions.php, screenshot. Then, inside the bootstrap folder I created two other folders CSS and JS.
So now I have :
- Child theme folder > boostrap > css
- Child theme forlder > bootstrap > js
In the CSS folder, I uploaded the "bootstrap.min.css" file and in the JS folder, I uploaded the "bootstrap.bundle.js" file.
After that, I modified the functions.php file with the code below, but this does not work when I add custom HTML using Elementor. Did I miss something in the code or is there anything else I should do ?
I have a little experience with HTML, CSS and Bootstrap, but I'm a novice in PHP and JavaScript.
function child_enqueue_styles() {
wp_enqueue_script( 'bootstrap-js', get_template_directory_uri() . '/bootstrap/js/bootstrap.bundle.js', array( 'jquery' ),'',true );
wp_enqueue_style('bootstrap5-css', get_template_directory_uri() . '/bootstrap/css/bootstrap.min.css');
wp_enqueue_style( 'my-site-theme-css', get_stylesheet_directory_uri() . '/style.css', array('astra-theme-css'), CHILD_THEME_MY_SITE_VERSION, 'all' );
}
add_action( 'wp_enqueue_scripts', 'child_enqueue_styles', 15 );
It's been 3 hours now that I'm trying to implement this, and it's driving me crazy.
Thank you very much for your help !
I want to add Bootstrap to a WordPress child theme that I edit using Elementor.
To do that, I used both CDN and bootstrap local files but neither worked. For the local files, I created a bootstrap folder in my child theme folder where I had only three folders : functions.php, screenshot. Then, inside the bootstrap folder I created two other folders CSS and JS.
So now I have :
- Child theme folder > boostrap > css
- Child theme forlder > bootstrap > js
In the CSS folder, I uploaded the "bootstrap.min.css" file and in the JS folder, I uploaded the "bootstrap.bundle.js" file.
After that, I modified the functions.php file with the code below, but this does not work when I add custom HTML using Elementor. Did I miss something in the code or is there anything else I should do ?
I have a little experience with HTML, CSS and Bootstrap, but I'm a novice in PHP and JavaScript.
function child_enqueue_styles() {
wp_enqueue_script( 'bootstrap-js', get_template_directory_uri() . '/bootstrap/js/bootstrap.bundle.js', array( 'jquery' ),'',true );
wp_enqueue_style('bootstrap5-css', get_template_directory_uri() . '/bootstrap/css/bootstrap.min.css');
wp_enqueue_style( 'my-site-theme-css', get_stylesheet_directory_uri() . '/style.css', array('astra-theme-css'), CHILD_THEME_MY_SITE_VERSION, 'all' );
}
add_action( 'wp_enqueue_scripts', 'child_enqueue_styles', 15 );
It's been 3 hours now that I'm trying to implement this, and it's driving me crazy.
Thank you very much for your help !
Share Improve this question edited May 31, 2021 at 5:57 bueltge 17.1k7 gold badges62 silver badges97 bronze badges asked May 28, 2021 at 16:25 DownforuDownforu 1032 bronze badges1 Answer
Reset to default 1get_template_directory_uri() always points to the parent theme.
To get the child theme use get_stylesheet_directory_uri().
本文标签: How to install Bootstrap in a WordPress child theme
版权声明:本文标题:How to install Bootstrap in a WordPress child theme 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741529896a2383690.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论