简体   繁体   中英

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

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/bootstrap@4.6.0/dist/js/bootstrap.min.js', array( 'jquery' ), '4.6.0', true);
wp_enqueue_style( 'bootstrap-css', 'https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM