Grow your CSS skills. Land your dream job.

Scripts not loading in wordpress

  • # July 2, 2013 at 3:53 pm

    Hi, I am trying to load some scripts in wordpress the proper way but it is not working.
    In my functions.php file I have this:

    	add_action('wp_enqueue_scripts', 'ls_scripts');
    function ls_scripts() {
    if (!is_admin()) {
    wp_enqueue_style( 'ls-css', get_template_directory_uri() . '/css/liquid-slider.css');
    wp_enqueue_script( 'jquery-easing', get_template_directory_uri() . '/js/jquery.easing.1.3.js', array('jquery'), '', true );
    wp_enqueue_script( 'jquery-touchSwipe', get_template_directory_uri() . '/js/jquery.touchSwipe.min.js', array('jquery-easing'), '', true );
    wp_enqueue_script( 'jquery-ls', get_template_directory_uri() . '/js/jquery.liquid-slider.min.js', array('jquery-touchSwipe'), '', true );
    }
    }

    The css file is loading fine but the javascript files aren't loading at all but I cannot work out why.
    Can anybody help?

    Thanks in advance,
    Matt

    # July 2, 2013 at 4:46 pm

    I have now made it work but only by getting rid of the reliance on jquery which obviosly isn’t ideal. Any ideas why it isn’t finding that jquery is loaded?

    This is my code for loading jquery:


    if ( !function_exists( 'core_mods' ) ) {
    function core_mods() {
    if ( !is_admin() ) {
    wp_deregister_script( 'jquery' );
    wp_register_script( 'jquery', ( "//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ), false);
    wp_enqueue_script( 'jquery' );
    }
    }
    add_action( 'wp_enqueue_scripts', 'core_mods' );
    }

    Matt

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".