Oisín Bowles
Oisín Bowles

Reputation: 13

How to add Bootstrap jQuery to WordPress

I am learning WordPress and am transferring a basic bootstrap template to Wordpress so I can them edit it, but I can't get the jQuery to work.

I have this code saved in my functions.php file in my theme folder.

 <?php

function test_resources() {

wp_enqueue_script( 'bootstrap.min.js', get_template_directory_uri(). 'js/bootstrap.min.js', array( 'jquery' ) );
wp_enqueue_script( 'jquery.easing.min.js', get_template_directory_uri(). 'js/jquery.easing.min.js', array( 'jquery' ) );
wp_enqueue_script( 'scrolling-nav.js', get_template_directory_uri(). 'js/scrolling-nav.js', array( 'jquery' ) );

}

add_action('wp_enqueue_scripts', 'test_resources');

Upvotes: 0

Views: 1564

Answers (2)

Klaudio Milankovic
Klaudio Milankovic

Reputation: 351

You need to add a slash before the path '/js/bootstrap.min.js'

function test_resources() {

wp_enqueue_script( 'bootstrap.min.js', get_template_directory_uri(). '/js/bootstrap.min.js', array( 'jquery' ) );

wp_enqueue_script( 'jquery.easing.min.js', get_template_directory_uri(). '/js/jquery.easing.min.js', array( 'jquery' ) );

wp_enqueue_script( 'scrolling-nav.js', get_template_directory_uri(). '/js/scrolling-nav.js', array( 'jquery' ) );

}

add_action('wp_enqueue_scripts', 'test_resources');

Upvotes: 1

MrRobot9
MrRobot9

Reputation: 2684

You have to call the jQuery yourself using this.

wp_enqueue_script('jquery');  

Upvotes: 2

Related Questions