Home > Net >  How to enqueue Bootstrap 4.6 js & css from local files for use in Wordpress
How to enqueue Bootstrap 4.6 js & css from local files for use in Wordpress

Time:01-22

I currently have Bootstrap 4.6 js and css loading from Bootstrap CDNs in WordPress via wp_enqueue_script and wp_enqueue_style respectively in the functions.php file

wp_enqueue_script( 'bootstrap-js', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js', array( 'jquery' ), '4.6.0', true);
wp_enqueue_style( 'bootstrap-css', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css', array(), '4.6.0', 'all' );

BUT I would like to source both these files from downloaded resources

Unfortunately I don't have enough knowledge to be certain of writing these enqueue instructions correctly _ The source address is not so much the problem, I'm specifically seeking help on how to complete the array element of the code-line, and any other additions that might be required:

JS - array( 'jquery' ), '4.6.0', true); and CSS - array(), '4.6.0', 'all' );

Thanks in advance for any advice

CodePudding user response:

wp_enqueue_script( 'bootstrap-js', get_template_directory_uri() . '/js/bootstrap.min.js', array( 'jquery' ), '4.6.0', true);
wp_enqueue_style( 'bootstrap-css', get_template_directory_uri() . '/css/bootstrap.min.css', array(), '4.6.0', 'all' );

make sure your js and css path inside the theme folder is correct according to your folder structure.

  • Related