Catatan Load JS File di WordPress

Posted: April 29, 2014 in Komputer, Wordpress
Tags: ,

Ini untuk load file Javascript tambahan yang memerlukan Jquery sebagai dependensinya:

function load_scripts() {
wp_enqueue_script('jquery');
wp_enqueue_script('scripts', get_template_directory_uri() . '/js/scripts.js');}
add_action('wp_enqueue_scripts', 'load_scripts');

Kode tersebut ditaruh di functions.php

Cara kedua adalah:

<script src="<?php echo get_template_directory_uri(); ?>/js/jquery.js" type="javascript"></script>

 

Jquery.js bisa diganti dengan Javascript apapun

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s