themes - Loading Bootstrap with wp_enqueue_style and wp_enqueue_script

I'm looking to load Bootstrap on a theme I'm working on though can't figure out how to add the JS file th

I'm looking to load Bootstrap on a theme I'm working on though can't figure out how to add the JS file that comes with Bootstrap. I already created a function that loads some of my custom styles and it works great, afterwards I downloaded Bootstrap, moved the file into my theme directory and added

wp_enqueue_style('bootstrap', get_template_directory_uri() .       'css/bootstrap.min.css');

I haven't tried that so I don't know if it works or not, now I just have to add the bootstrap.min.js file but can't figure out how, so your help would be appreciated.

This is my code so far

<?php 

function xobamax_resources() {

    wp_enqueue_style('bootstrap', get_template_directory_uri() . 'css/bootstrap.min.css');
    wp_enqueue_style('style', get_stylesheet_uri());


}

add_action('wp_enqueue_scripts', 'xobamax_resources');

I'm looking to load Bootstrap on a theme I'm working on though can't figure out how to add the JS file that comes with Bootstrap. I already created a function that loads some of my custom styles and it works great, afterwards I downloaded Bootstrap, moved the file into my theme directory and added

wp_enqueue_style('bootstrap', get_template_directory_uri() .       'css/bootstrap.min.css');

I haven't tried that so I don't know if it works or not, now I just have to add the bootstrap.min.js file but can't figure out how, so your help would be appreciated.

This is my code so far

<?php 

function xobamax_resources() {

    wp_enqueue_style('bootstrap', get_template_directory_uri() . 'css/bootstrap.min.css');
    wp_enqueue_style('style', get_stylesheet_uri());


}

add_action('wp_enqueue_scripts', 'xobamax_resources');
Share Improve this question asked Feb 6, 2016 at 15:43 OulaXOulaX 11 gold badge1 silver badge1 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 6

Here you go..

function xobamax_resources() {
    wp_enqueue_style('bootstrap', get_template_directory_uri() . 'css/bootstrap.min.css');
    wp_enqueue_style('style', get_stylesheet_uri());
    wp_enqueue_script( 'bootstrap-js', 'https://maxcdn.bootstrapcdn/bootstrap/3.3.4/js/bootstrap.min.js', array('jquery'), '3.3.4', true );
}
add_action('wp_enqueue_scripts', 'xobamax_resources');

I have added the CDN version, You can replace that with your local copy. I want to suggest you to read more about wp_enqueue_script()

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742255655a4409971.html

相关推荐

  • themes - Loading Bootstrap with wp_enqueue_style and wp_enqueue_script

    I'm looking to load Bootstrap on a theme I'm working on though can't figure out how to add the JS file th

    1天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信