2016-10-02 5 views
0

子テーマを作成し、子テーマにpage-splash.phpを作成してこのページ用のsplash.cssを作成しましたが、どういうわけかpage-splash.cssをpage-splash.phpファイルに読み込めません。子テンプレートにページテンプレート用のスタイルシートを含めることができません

これは、私がこれについてあなたの助けを本当に感謝します(子テーマフォルダに)

<?php 

add_action('wp_enqueue_scripts', 'my_theme_enqueue_styles'); 
function my_theme_enqueue_styles() { 
    wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css'); 

} 

function splash_enqueue_style() { 
    wp_enqueue_style('page-splash', get_template_directory_uri().'/css/page-spash.css'); 
} 
add_action('wp_enqueue_scripts', 'splash_enqueue_style'); 


?> 

のfunctions.phpで私のコードです。 私は何が間違っていますか? 私はlocalhostで作業しており、正常に動作した後、これらのファイルを作業ドメインに転送します。

答えて

0

まあ、私は答えを探し続けており、私はそれを見つけました。 すべてのjavacript またはcssファイルを読み込みたい場合は、wp_head()を使用することが重要です。

+0

そうそう、この情報はあまりにも –

1

最も簡単なものから始まります。あなたはpage-splash.cssファイルパスに入力ミスがあります。あなたはpage-spash.cssとタイプされています

さらに、2つの別々の関数を呼び出す必要はありません。あなたはそうのように1回の呼び出しでこれらのスタイルの両方をエンキューできます。

function splash_enqueue_style() { 
    wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css'); 
    if(is_page_template('page-splash.php'){ 
     //Path to your template.. if it's in a dir, include it before the file 
     wp_enqueue_style('page-splash', get_template_directory_uri().'/css/page-splash.css'); 
    } 
} 
add_action('wp_enqueue_scripts', 'splash_enqueue_style'); 
+0

おかげで、私はこれを試してみるということ。 ちなみに、私はpage-splash.cssが親テーマのCSSファイルによって上書きされているように見えるので、問題が発生しています。 どうすれば修正できますか? – faraz

+0

「オーバーライド」とはどういう意味ですか?スプラッシュスタイルがページに読み込まれていますが、その中のすべてのCSSがオーバーライドされていますか?代わりにファイルがまったく読み込まれていませんか? –

関連する問題