i tried enqueue the bootstap with functions php
wp_enqueue_style('bootstrap4', '.1.1/css/bootstrap.min.css');
wp_enqueue_script( 'boot1','.3.1.slim.min.js');
wp_enqueue_script( 'boot2','.js/1.14.3/umd/popper.min.js');
wp_enqueue_script( 'boot2','.1.1/js/bootstrap.min.js');
css seems to work but none of the js files are working..not sure what i am doing wrong..
please help thank
i tried enqueue the bootstap with functions php
wp_enqueue_style('bootstrap4', 'https://stackpath.bootstrapcdn/bootstrap/4.1.1/css/bootstrap.min.css');
wp_enqueue_script( 'boot1','https://code.jquery/jquery-3.3.1.slim.min.js');
wp_enqueue_script( 'boot2','https://cdnjs.cloudflare/ajax/libs/popper.js/1.14.3/umd/popper.min.js');
wp_enqueue_script( 'boot2','https://stackpath.bootstrapcdn/bootstrap/4.1.1/js/bootstrap.min.js');
css seems to work but none of the js files are working..not sure what i am doing wrong..
please help thank
Share Improve this question asked Jun 16, 2018 at 17:07 user145078user145078 2 |2 Answers
Reset to default 7You can use action hook and enqueue script and style to the site.
function my_scripts() {
wp_enqueue_style('bootstrap4', 'https://stackpath.bootstrapcdn/bootstrap/4.1.1/css/bootstrap.min.css');
wp_enqueue_script( 'boot1','https://code.jquery/jquery-3.3.1.slim.min.js', array( 'jquery' ),'',true );
wp_enqueue_script( 'boot2','https://cdnjs.cloudflare/ajax/libs/popper.js/1.14.3/umd/popper.min.js', array( 'jquery' ),'',true );
wp_enqueue_script( 'boot3','https://stackpath.bootstrapcdn/bootstrap/4.1.1/js/bootstrap.min.js', array( 'jquery' ),'',true );
}
add_action( 'wp_enqueue_scripts', 'my_scripts' );
If you want to add the scripts after jQuery then you can use the jQuery array for dependent and last argument true will include the JS at footer, if you want the js in header, you can remove that.
Try this:
function abc_load_my_scripts() {
wp_enqueue_script( 'boot1','https://code.jquery/jquery-3.3.1.slim.min.js', array('jquery'));
wp_enqueue_script( 'boot2','https://cdnjs.cloudflare/ajax/libs/popper.js/1.14.3/umd/popper.min.js', array('jquery'));
wp_enqueue_script( 'boot3','https://stackpath.bootstrapcdn/bootstrap/4.1.1/js/bootstrap.min.js', array('jquery'));
}
add_action( 'wp_enqueue_scripts', 'abc_load_my_scripts', 999);
With the last argument array('jquery')
you're telling WP to include the script AFTER jQuery. Note that every script must use a different handle (first parameter).
More info here.
When you check the <head>
, are you certain the scripts aren't loaded?
Regards, Bjorn
wp_head()
? – Nathan Johnson Commented Jun 16, 2018 at 17:25