ページ内目次

子テーマから親テーマのスタイルシートを読み込む

子テーマを適用した場合に、何らかの理由で親テーマのスタイルシートを強制的に読み込ませる必要がある場合があります。

そんな時の方法です。

 

子テーマ側のスタイルシートのヘッダー部分が正しく設定さそれていて、親テーマとの主従関係は正しく設定されているという前提で…

子テーマ側の functions.phpに

<?php
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}

これだけ

 

@importは、もうかなり以前から非推奨なので使用しません。

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny

↑上へまいりま〜す