Skip to content

Instantly share code, notes, and snippets.

@miya0001
Created June 3, 2012 19:54
Show Gist options
  • Save miya0001/2864806 to your computer and use it in GitHub Desktop.
Save miya0001/2864806 to your computer and use it in GitHub Desktop.
リバースプロキシやCDN,キャッシュ系のプラグインと仲良しで子テーマにも対応しやすいCSSの読み込み方
<link rel="stylesheet" type="text/css" media="all" href="<?php echo get_template_directory_uri(); ?>/style.css?ver=<?php echo filemtime(get_template_directory().'/style.css'); ?>" />
<?php if (is_child_theme()): ?>
<link rel="stylesheet" type="text/css" media="all" href="<?php echo get_stylesheet_directory_uri(); ?>/style.css?ver=<?php echo filemtime(get_stylesheet_directory().'/style.css') ?>" />
<?php endif; ?>
@miya0001
Copy link
Author

miya0001 commented Jun 3, 2012

自作テーマを作るときに親テーマにこんな風に書いておけば、子テーマサイドにはstyle.cssを置くだけでいいし、@importを使うよりも表示速度がやや高速化できる。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment