2017-01-05 1 views
0

いくつかの試行錯誤の末、私はtwentysixteenの以前のように22歳の子供のテーマを作成したように見えますが、ダッシュボードに私のテーマに選んだ名前が表示されますが、ロードされたスタイルシートは私子テーマのstyle.cssを修正し、元のtwentyseventeen.cssをロードしています。レンダリングされたページには<link rel='stylesheet' id='twentyseventeen-style-css' href='https://cjshayward.com/wp-content/themes/twentyseventeen/style.css?ver=4.7' type='text/css' media='all' />が含まれます。チャイルドテーマのWP 22でスタイルシートを指定するにはどうすればよいですか?私が選んだ子供のテーマを登録するには何が必要ですか?

親テーマのスタイルシートの代わりに独自のテーマを使用するように子テーマを変更するにはどうすればよいですか?

私のfunctions.phpは読む:

<?php 
update_option('siteurl', 'https://cjshayward.com'); 
update_option('home', 'https://cjshayward.com'); 
add_action('wp_enqueue_scripts', 'theme_enqueue_styles'); 
function theme_enqueue_styles() { 
wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css'); 

} 
?> 

はこれまでのところ、私が試したすべてのものは、独自のスタイルシート、 /wp-content/themes/twentyseventeen-ux-tweaks-child/style.cssからロードするようにそれを得るために失敗しました。編集 functions.phpは機能しませんでした。 header.phpの編集はうまくいきませんでしたが、二次的なダメージがあるかどうかは疑問に思っていますが、22世紀のオリジナルではなく私の子供のテーマを使用するように正式に言わなかったからです。 get_template_directory_uri()'/wp-content/themes/twentyseventeen-ux-tweaks-childに置き換えると機能しませんでした。私はおそらく、私はApacheのURLの書き換えをしたいものを得ることができますが、私は実際に を知りたいです Wordpressでこれを行う方法。

子テーマを正しく登録して、提供された子テーマのstyle.cssをそのスタイルシートとして使用するには、何が必要ですか?

おかげで、

--UPDATE--

は私のfunctions.phpは今読み:

<?php 
update_option('siteurl', 'https://cjshayward.com'); 
update_option('home', 'https://cjshayward.com'); 

function my_theme_enqueue_styles() { 
    $parent_style = 'twentyseventeen'; 
    wp_enqueue_style($parent_style, get_template_directory_uri() . 
     '/style.css'); 
    wp_enqueue_style('twentyseventeen-ux-tweaks-child', 
     get_stylesheet_directory_uri() . '/style.css', 
     array($parent_style) 
    ); 
} 
add_action('wp_enqueue_scripts', 'my_theme_enqueue_styles'); 
?> 

私は以前と同じ振る舞いを経験しています。 https://cjshayward.com/wp-content/theme/twentyseventeen-ux-tweaks-child/style.cssが要素の検査とスタイルシートのトレースをまだ見ていません。

+0

あなたは子供を含む、子テーマのスタイルシートのヘッダーにコメントを挿入していますテーマとテンプレート名? – Johannes

答えて

1

wordpress.orgによると、それはそれがあるべきよう、親スタイルと子テーマのスタイルの両方をenqeueする必要があります:

<?php 
update_option('siteurl', 'https://cjshayward.com'); 
update_option('home', 'https://cjshayward.com'); 

function my_theme_enqueue_styles() { 
    $parent_style = 'twentyseventeen'; 
    wp_enqueue_style($parent_style, get_template_directory_uri() . '/style.css'); 
    wp_enqueue_style('twentyseventeen-ux-tweaks-child', 
     get_stylesheet_directory_uri() . '/style.css', 
     array($parent_style) 
    ); 
} 
add_action('wp_enqueue_scripts', 'my_theme_enqueue_styles'); 
?> 
+0

ありがとうございます。更新された質問を確認できますか? – JonathanHayward

+0

はい、そうでしょう。私はちょうどあなたの特定のテーマの名前を挿入して挿入していないが、私はちょうどそれを編集しました。 – Johannes

関連する問題