functions.php内で条件分岐タグを指定しても適用されない
-
現在TwentyTwelveを元に、子テーマを作成しております。
functions.php内にcssを設定する方法を調べ、こちらは適用させることができたのですが、その中で条件分岐タグ(if ( is_single() ))を入れてみるとその中のcssだけ適用されません。管理パネルに適用されないようにするif ( !is_admin() )はうまく行ってるのですが、それ以降が読み込まれません。
条件分岐タグを外した状態でfunctions.phpを更新するとcssが適用されるため、何か間違ってるのかと二つほどサイトを参考にしましたが、結局わかりませんでした。(こちらとこちらです)
(現在作ってるのとは別の)本サイトではheader内に直接分岐タグで適用させてますが、cssの記述方法を統一できた方がコードも綺麗なのではないかと思い、四苦八苦しています。
間違っているところがありましたら、指摘をお願いします。functions内はこんな感じで適用させています。
<?php //********************************************************************************** // スタイルシートの読み込み //********************************************************************************** if ( !is_admin() ) { wp_enqueue_style( 'twentytwelve-style', get_template_directory_uri() . '/style.css', date('YmdHis', filemtime(get_template_directory() . '/style.css')) //filetimeで更新した日付を取得してバージョンに入れる ); wp_enqueue_style( 'twentytwelve-child-style', get_stylesheet_uri(), array('twentytwelve-style') , date('YmdHis', filemtime(get_template_directory() . '/style.css')) ); if ( is_single() ) { wp_enqueue_style( 'post-style', get_stylesheet_directory_uri() . '/post.css', array('twentytwelve-child-style'), date('YmdHis', filemtime(get_stylesheet_directory() . '/post.css'))); } else if ( is_page() ) { wp_enqueue_style( 'page-style', get_stylesheet_directory_uri() . '/page.css', array('twentytwelve-child-style'), date('YmdHis', filemtime(get_stylesheet_directory() . '/page.css'))); } }(page.cssは何もいじってませんので、そっちは未確認です)
2件の返信を表示中 - 1 - 2件目 (全2件中)
2件の返信を表示中 - 1 - 2件目 (全2件中)
トピック「functions.php内で条件分岐タグを指定しても適用されない」には新たに返信することはできません。