外部javascriptの追加

前提
テーマファイルディレクトリ直下にディレクトリjsがあり、その中に、custom_script.jsが存在するものとする。

if ( !is_admin() ) { 
  // instruction to only load if it is not the admin area
 // register your script location, dependencies and version
 wp_register_script('custom_script',
 get_bloginfo('stylesheet_directory') .'/js/custom_script.js',array(),'1.0' );
 // enqueue the script
 wp_enqueue_script('custom_script');
}

jQuery等、依存するフレームワーク等があるときには、上記コードの空の配列に、array(‘jquery’)とする。

1.0は、スクリプトのバージョン、省略するとwordpressのバージョンが使われる

http://codex.wordpress.org/Function_Reference/wp_enqueue_script(codex wp_enqueue_script)

[emulsion_relate_posts]