0

Here is what I've done so far

in functions.php

function imk_scripts() {
    wp_enqueue_script(
        'bootstrap_js',
        get_template_directory_uri() . '/js/bootstrap.min.js',
        array('jquery'),
        '3.3.5',
        true
    );
    wp_enqueue_script(
        'plugin_js',
        get_template_directory_uri() . '/js/plugins.js',
        array(''),
        '1.0',
        true
    );
    wp_enqueue_script(
        'bskit_js',
        get_template_directory_uri() . '/js/bskit-scripts.js',
        array(''),
        '1.0',
        true
    ); 
}

add_action( 'wp_enqueue_scripts', 'imk_scripts' );

in footer.php

    <script type="text/javascript" src="<?php get_template_directory_uri(); ?>/js/bootstrap.min.js"></script>         
    <script type="text/javascript" src="<?php get_template_directory_uri(); ?>/js/plugins.js"></script>
    <script src="<?php get_template_directory_uri(); ?>/https://maps.google.com/maps/api/js?sensor=true"></script>
    <script type="text/javascript" src="<?php get_template_directory_uri(); ?>/js/bskit-scripts.js"></script>   

but the scripts are not loading... what am I doing wrong?

  • 1
    why are you manually inserting scripts in footer.php ? – WPTC-Troop Feb 9 '16 at 7:03
1

Firstly, you don't need to add scripts in footer.php manually.

Secondly, if there are no script dependencies, you have to declare empty array:

array(), rather than array('').

Due this mistake scripts are not loading except Bootstrap.

The correct code is:

function imk_scripts() {
    wp_enqueue_script(
        'bootstrap_js',
        get_template_directory_uri() . '/js/bootstrap.min.js',
        array('jquery'),
        '3.3.5',
        true
    );
    wp_enqueue_script(
        'plugin_js',
        get_template_directory_uri() . '/js/plugins.js',
        array(),
        '1.0',
        true
    );
    wp_enqueue_script(
        'bskit_js',
        get_template_directory_uri() . '/js/bskit-scripts.js',
        array(),
        '1.0',
        true
    ); 
}
add_action( 'wp_enqueue_scripts', 'imk_scripts' );

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.