user3538333
user3538333

Reputation: 1

Linking wordpress custom bootstrap stylesheet

I'm trying to link my WordPress Stylesheet to child theme at different directory/sub folder, it doesn't seems to work. Below are the code where I place it at functions.php

function theme_add_bootstrap()
{
    wp_enqueue_style( 'bootstrap-css', get_template_directory_uri() . 'assets/css/bootstrap.min.css' );
    wp_enqueue_style( 'style-css', get_template_directory_uri() . 'assets/css/custom.css' );
    wp_enqueue_script( 'bootstrap-js', get_template_directory_uri() . 'assets/js/bootstrap.min.js', array(), '3.0.0', true );
}

add_action( 'wp_enqueue_scripts', 'theme_add_bootstrap' );

I try putting @import statement inside style.css, it doesn't work also.

Upvotes: 0

Views: 133

Answers (1)

Akshay Paghdar
Akshay Paghdar

Reputation: 3629

Use this:-

function theme_add_bootstrap()
{
    wp_enqueue_style( 'bootstrap-css', get_template_directory_uri() . '/assets/css/bootstrap.min.css' );
    wp_enqueue_style( 'style-css', get_template_directory_uri() . '/assets/css/custom.css' );
    wp_enqueue_script( 'bootstrap-js', get_template_directory_uri() . '/assets/js/bootstrap.min.js', array(), '3.0.0', true );
}

add_action( 'wp_enqueue_scripts', 'theme_add_bootstrap' );

Remember that get_template_directory_uri() will give you directory uri path with no /. SO you need to add / after this function.

Hope this will work for you.

Upvotes: 1

Related Questions