2021-04-27

Include Bootstrap 5 Using jQuery Into WordPress

I'm trying to upgrade from Bootstrap 4.6 to Bootstrap 5.0 into my WordPress theme. Below is how I include BS 5, jQuery and some custom JS file.

function add_theme_scripts() {
    wp_enqueue_style( 'style', get_template_directory_uri() . '/static/style.css');

    wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/static/js/bootstrap.bundle.min.js', array('jquery) );
    wp_enqueue_script( 'script', get_template_directory_uri() . '/static/js/min/build.min.js', array() );
        }
add_action( 'wp_enqueue_scripts', 'add_theme_scripts' );
  • As long as I was using BS 4.6 all was working fine but since I have upgraded to BS 5 the Accordion Component doesn't work anymore. It works only if I disable jQuery.
  • I don't get any console error.
  • I have updated all the BS components according to the new documentation. In fact all work but the Accordion one.
  • I am aware that BS 5 works better with Vanilla JS but for now I need both BS 5 and jQuery.

Any idea on how to achieve this? Thanks.



from Recent Questions - Stack Overflow https://ift.tt/2S75QED
https://ift.tt/eA8V8J

No comments:

Post a Comment