Created
December 8, 2017 02:24
-
-
Save senooat/6a188a5b80e5bcaa7cb2804c80b31f66 to your computer and use it in GitHub Desktop.
wp_head()やwp_footer()にCSSやJSを読み込む方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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