Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save senooat/6a188a5b80e5bcaa7cb2804c80b31f66 to your computer and use it in GitHub Desktop.
Save senooat/6a188a5b80e5bcaa7cb2804c80b31f66 to your computer and use it in GitHub Desktop.
wp_head()やwp_footer()にCSSやJSを読み込む方法
function load_inline_script(){
if ( function_exists( 'wp_add_inline_script' ) ) {
$tag = "(function($){
//ここに処理を記述
})(jQuery);";
//この場合は「tempjs-script」下に読み込ませるという設定
wp_add_inline_script('tempjs-script', $tag, 'after');
}
}
add_action('wp_enqueue_scripts', 'load_inline_script');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment