简体   繁体   中英

How to add bootstrap css to my Wordpress plugin

I am developing a Wordpress plugin.

I would like to know how to integrate a Bootstrap CSS file into my plugin?

create a function in your Plugin file

function add_scripts_and_css(){
  wp_enqueue_style('your-plugin-bootrtrap_css',  plugin_dir_url( __FILE__ ) . 'folderpath/bootstrap.css');
}

add_action('wp_enqueue_scripts', 'add_scripts_and_css');

This is the way to add wp_enqueue_style to add css files and wp_enqueue_script to add JavaScript .js files.

// load your plugin css into the website's front-end
function myplugin_enqueue_style() {
    wp_enqueue_style( 'myplugin-style', plugin_dir_url( __FILE__ )."css/bootstrap.css" ); 
}
add_action( 'wp_enqueue_scripts', 'myplugin_enqueue_style' );

Add above code in your plugin register_activation_hook .

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