Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save senooat/4fdc65ffbd8edd2bb2a7c385a4c769f0 to your computer and use it in GitHub Desktop.
Save senooat/4fdc65ffbd8edd2bb2a7c385a4c769f0 to your computer and use it in GitHub Desktop.
wp_head()やwp_footer()にCSSやJSを読み込む方法
<?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