1

I am trying to load my site's child theme's css after Bootstrap CDN css in wordpress. I tried using these code but it doesn't work. The Bootstrap css is not overriden. What should I do to fix that?

function override_css() {
    wp_enqueue_style( 'bootstrap.min', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css' );
    wp_enqueue_style( 'style', get_stylesheet_directory_uri() . '/style.css', array(), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'override_css' );
4
  • You can't override CSS that way. It will just load your CSS file after bootstrap. You will have to override CSS declarations within your CSS file.
    – Abhik
    Commented May 20, 2022 at 10:19
  • How are the parent theme's stylesheets enqueued? Commented May 20, 2022 at 10:34
  • Like this? I am not sure where to find define( 'ASTRA_THEME_DIR', trailingslashit( get_template_directory() ) ); define( 'ASTRA_THEME_URI', trailingslashit( esc_url( get_template_directory_uri() ) ) ); isn't loading my css after the bootstrap the way to override it?
    – wcwc
    Commented May 23, 2022 at 8:22
  • This answer talks about how to deregister a queued CSS - wordpress.stackexchange.com/a/340770/109240 Commented May 27, 2022 at 17:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.