0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

wordpressでcssとjsをfunctions.phpで読み込むときに気をつけること

Posted at

WordPressではfunctions.phpで一括でcssやjsの読み込みを管理することが多いです。
たまにcss/jsが反映されていないときには、$handle名をみてあげましょう!
実際に、このようなコードでは同じハンドル名が2つ存在してしまうので、正しく読み込むことができません。

functions.php
    wp_enqueue_style('my', get_template_directory_uri() . '/css/style.css', array(), '1.0.0', 'all');
    wp_enqueue_style('my', get_template_directory_uri() . '/css/tomorrow-night-eighties.css', array(), '10.3.2', 'all');

myが2つ存在しています。
こちらは別の名前に変更すると反映されるようになります!

functions.php
    wp_enqueue_style('my', get_template_directory_uri() . '/css/style.css', array(), '1.0.0', 'all');
    wp_enqueue_style('my1', get_template_directory_uri() . '/css/tomorrow-night-eighties.css', array(), '10.3.2', 'all');

コピペでやっていると結構見落としがちなところなので、反映しないときはまっさきに疑ってもいいかもしれません。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?