wp_enqueue_script bootstrap

To enqueue the Bootstrap script in WordPress, you can use the wp_enqueue_script function. You'll need to make sure that you have the Bootstrap files available in your theme or plugin directory before enqueueing them.

Here's an example of how you can enqueue the Bootstrap script:

function enqueue_bootstrap_script() {
    wp_enqueue_script( 'bootstrap-script', get_template_directory_uri() . '/path/to/bootstrap.min.js', array( 'jquery' ), '5.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'enqueue_bootstrap_script' );

In the example above, we're using the wp_enqueue_script function to enqueue the Bootstrap script. We provide a handle name for the script, in this case, 'bootstrap-script'. The second parameter is the path to the Bootstrap script file, which you'll need to adjust based on your file structure. You can use the get_template_directory_uri() function to get the URL of the current theme directory.

The third parameter, array( 'jquery' ), specifies that the Bootstrap script depends on jQuery. This ensures that jQuery is loaded before the Bootstrap script.

The fourth parameter, '5.0.0', is the version number of the Bootstrap script. You can change this to the version you're using.

The fifth parameter, true, indicates that the script should be loaded in the footer of the HTML document. This is recommended for performance reasons.

By adding this code to your theme's functions.php file or a custom plugin file, the Bootstrap script will be enqueued and loaded on your WordPress site.

Note: Make sure you have already included the Bootstrap CSS file in your theme or plugin. You can use the wp_enqueue_style function to enqueue the Bootstrap CSS file.