Reputation: 13
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
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
Reputation: 2684
You have to call the jQuery yourself using this.
wp_enqueue_script('jquery');
Upvotes: 2