Last active
December 8, 2017 01:57
-
-
Save senooat/4fdc65ffbd8edd2bb2a7c385a4c769f0 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
<?php | |
/*----------------------------------- | |
wp_head(),wp_footer()にJS,CSSを読み込み | |
-----------------------------------*/ | |
function add_files() { | |
if ( is_admin() ) return; | |
//ここに処理を記述 | |
} | |
add_action('wp_enqueue_scripts', 'add_files'); | |
//JSやCSSに自動で付与されるバージョン番号を非表示 | |
function vc_remove_wp_ver_css_js( $src ) { | |
if ( strpos( $src, 'ver=' ) ) | |
$src = remove_query_arg( 'ver', $src ); | |
return $src; | |
} | |
add_filter( 'style_loader_src', 'vc_remove_wp_ver_css_js', 9999 ); | |
add_filter( 'script_loader_src', 'vc_remove_wp_ver_css_js', 9999 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment