9

I want to add more than one external javascript files in wordpress theme, I have found code for adding one file, but I need to add more javascript files. How can I do it?

function wpTan_scripts() {
   wp_register_script('app', '/js/app.js', false);
   wp_enqueue_script( 'app' );
}
add_action('wp_enqueue_scripts', 'wpTan_scripts');

1 Answer 1

15

you can add as many scripts as you want.

function themeslug_enqueue_script() {
    wp_enqueue_script( 'jquery-v-2', 'http://code.jquery.com/jquery-2.1.3.min.js', false );
    wp_enqueue_script( 'mycustomJs', 'file_name.js', false );
    // here you can enqueue more js / css files 
}

add_action( 'wp_enqueue_scripts', 'themeslug_enqueue_script' );
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.