Support » Fixing WordPress » Problem loading scripts from functions.php

  • Hi there!

    I’ve been trying to integrate the carouFredSel caroussel jQuery plugin on my site using this tutorial: http://wp.tutsplus.com/tutorials/theme-development/displaying-posts-in-a-carousel/

    The idea is to load the jQuery script as well as the carouFredSel script in functions.php and then be able to use it on any desired page. jQuery loaded fine, but the carouFredSel script didn’t. In order to get it working I had to include the following code on the page desired: <script type="text/javascript" src="http://frisoer.cbo.dk/wp-content/themes/responsive-child-theme/js/jquery.carouFredSel-6.1.0-packed.js"></script>

    I’ve read somewhere that this is not the proper way to load a script and that it should be loaded via functions.php instead. Unfortunately, I haven’t had luck getting this to work.

    My functions.php (child) looks as follows:

    <?php
    
    function my_scripts_method() {
    
    $jQuery = "http://code.jquery.com/jquery-latest.min.js";
    wp_deregister_script( 'jQuery' );
    wp_register_script( 'jQuery', $jQuery);
    wp_enqueue_script( 'jQuery');
    
    wp_register_script( 'carouFredSel', get_template_directory_uri() . '/wp-content/themes/responsive-child-theme/js/jquery.carouFredSel-6.1.0-packed.js',
    		array('jquery'), '5.5.0', true );
    
    wp_enqueue_script( 'stinnacarou',  get_template_directory_uri() . 'http://frisoer.cbo.dk/wp-content/themes/responsive-child-theme/js/stinnacarou.js', array('carouFredSel'), '', true);
    
    }
    add_action('wp_enqueue_scripts', 'my_scripts_method');
    add_filter('wp_enqueue_scripts','my_scripts_method');
    ?>

    jQuery seems to load just fine, but does anyone have any idea why the carouFredSel script is unable to load from functions.php?

    Thanks in advance!

    /Martin

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Problem loading scripts from functions.php’ is closed to new replies.