
長いタイトルですが、親テーマのstyle.cssが子テーマを適用した際にも呼び出されるようにするコードをfunctions.phpに記入したのですが、親テーマのcssが呼び出せていません。呼び出せていないとは、styleシートが聞いていないつまり色とか全くない状態でhy
参考サイト
僕の認識が正しいか聞きたいのですが、
php
1<?php //子テーマで利用する関数を書く 2 3add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); 4function theme_enqueue_styles() { 5 wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); 6 7}
このコードは、どっちのテーマのfunction.phpに記入するのですか?
私は子テーマのfunction.phpに書いたのですが親テーマのstyle.cssを呼び出せていないもので・・・
また、このコードって最後に
php
1?>
を入れないとダメですよね?笑
閉じタグがないと作動しないと思ったのですが・・・
また、このサイトに書かれているように@importを利用して呼び出す方法は時代遅れですよね?
別のコードで子テーマのfunction.phpに書きましたが、結果は一緒で親テーマのcssが反映されていません。
php
1<?php 2add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); 3function theme_enqueue_styles() { 4 wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); 5 wp_enqueue_style( 'child-style', 6 get_stylesheet_directory_uri() . '/style.css', 7 array('parent-style') 8 ); 9} 10?>
回答1件
あなたの回答
tips
プレビュー