0

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');
2

2 Answers 2

2

You have to call the jQuery yourself using this.

wp_enqueue_script('jquery');  
Sign up to request clarification or add additional context in comments.

Comments

1

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');

2 Comments

yeah all it needed was a slash before the path. Thanks a million, feel like an idiot not seeing that, just needed fresh eyes to see it because I was staring at it for too long.
Yeah :) Happened to me couple of times, that's how I've noticed. No problem.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.