1

I am transferring boostrap theme to WordPress and trying to add JavaScript files in functions.php and execution shows no error:

<?php
function regload_javascripts() //need to register first
{
   wp_register_script('bootstrapjs',  get_template_directory_uri().'/js/bootstrap.js',array('jquery'),'1.1', true);
   wp_enqueue_script('bootstrapjs');
   wp_register_script('carousel',  get_template_directory_uri().'/js/carousel.js',array('jquery'),'1.1', true);
   wp_enqueue_script('carousel');
   wp_register_script('custom',  get_template_directory_uri().'/js/custom.js',array('jquery'),'1.1', true);
   wp_enqueue_script('custom');
   wp_register_script('flexslider',  get_template_directory_uri().'/js/flexslider.js',array('jquery'),'1.1', true);
   wp_enqueue_script('flexslider');
   wp_register_script('jquery182',  get_template_directory_uri().'/js/jquery-1.8.2.js',array('jquery'),'1.1', true);
   wp_enqueue_script('jquery182');
   wp_register_script('cslider',  get_template_directory_uri().'/js/jquery.cslider.js',array('jquery'),'1.1', true);
   wp_enqueue_script('cslider');
   wp_register_script('gmap_min', get_template_directory_uri().'/js/jquery.gmap.min.js',array('jquery'),'1.1', true);
   wp_enqueue_script('gmap_min');
   wp_register_script('slider',  get_template_directory_uri().'/js/slider.js',array('jquery'),'1.1', true);
   wp_enqueue_script('slider');
}

add_action ('wp_enqueue_scripts', 'regload_javascripts');

But there is no effect.

The js files are here: js files

My dev console output is :

TypeError: $ is undefined carousel.js:3:6079    <anonymous> http://localhost/wordpress/wp-content/themes/bootgotya/js/carousel.js?ver=1:3
TypeError: $ is not a function flexslider.js:14:2     <anonymous> http://localhost/wordpress/wp-content/themes/bootgotya/js/flexslider.js?ver=1:14 
Loading failed for the <script> with source “http://localhost/wordpress/js/flexslider.js”. wordpress:590:1 
Loading failed for the <script> with source “http://localhost/wordpress/js/carousel.js”. wordpress:591:1 
Loading failed for the <script> with source “http://localhost/wordpress/js/jquery.cslider.js”. wordpress:592:1
  • Are you sure the files are in the correct directory? Are you sure jquery is loaded? A screenshot doesn't say anything. The scripts could be loaded but used incorrectly elsewhere in the code. – cjbj Apr 5 at 19:00
  • 1
    What does your dev console say? Are there errors? Without knowing what the javascript is it's not possible to answer this question with just the information provided, please update your question via the edit link to include as much info as possible. Also, you shouldn't enqueue the jQuery 1.8.2 file, WP already has jQuery, and it might clash with your own version – Tom J Nowell Apr 5 at 19:16
  • Yes, the directory if ok. Jquery is loaded, because previously there was a problem with insufficient memory: solved it with var $ = jQuery.noConflict(); – Bex Apr 5 at 19:27
  • updated wit js files attached. – Bex Apr 5 at 19:33
  • After removing enqueue the jQuery 1.8.2 file. The issue was solved!!! :) Thank you very much guys for instant help!!! – Bex Apr 5 at 19:38
0

As was mentioned in comments and recommendations above, the removal of script for jQuery 1.8.2 file resolved my problem. Thank you to all :)!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.