Home > Back-end >  How can I use BOOTSTRAP in WORDPRESS?
How can I use BOOTSTRAP in WORDPRESS?

Time:06-01

I'm new to WORDPRESS is it possible to use or import bootstrap in my custom plugin? If not is there any kind of like bootstrap that I can use in designing my plugin?

CodePudding user response:

You need to modify the file header.php of the theme that you are using, in the editor this file may be described as "Theme Header". You need to link it to bootstrap:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">

This is the link they currently provide, though you can copy this directly from their webpage: https://getbootstrap.com/docs/4.5/getting-started/introduction

Notice that you are making changes to your theme file, so if the theme is updated your added code might be removed. To solve this you should use a child theme, which allows you to make changes that aren't overridden by theme updates.

If you want to add bootstrap using the built-in editor I recommend you use one tutorial by steps, like this one: https://www.inmotionhosting.com/support/edu/wordpress/how-to-use-bootstrap-in-wordpress/

Once bootstrap is installed you should be able to use it as usual.

CodePudding user response:

function prefix_theme_name_styles() {
    wp_enqueue_style( 'style', get_stylesheet_uri() );
    wp_enqueue_style( 'slider', 'cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css', array(), '1.0.0', 'all');
}
add_action( 'wp_enqueue_scripts', 'prefix_theme_name_styles' );

you can use the code for adding bootstrap in your plugin. Aso you can download the bootstarap and add it your plugin folder then enqueue it 

function add_my_stylesheet() 
{
    wp_enqueue_style( 'bootstrap', plugins_url( '/css/bootstrap.css', __FILE__ ) );
}

add_action('wp_enqueue_scripts', 'add_my_stylesheet');

  • Related