子テーマの取得方法(エラーが起こった場合も追記)

必要なのは、style.css のみ(基本的には)

【style.css】
・必須入力内容は、以下の赤文字部分
・大文字小文字に注意する。FTPで親テーマのフォルダを確認すること。

/*
Theme Name: Twenty Fifteen Child

Theme URI: http://example.com/twenty-fifteen-child/
Description: Twenty Fifteen Child Theme
Author: John Doe
Author URI: http://example.com
Template: twentyfifteen
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: twenty-fifteen-child
*/

/*
Theme Name: Twenty Fifteen Child
Theme URI: http://example.com/twenty-fifteen-child/
Description: Twenty Fifteen Child Theme
Author: John Doe
Author URI: http://example.com
Template: twentyfifteen
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: twenty-fifteen-child
*/

【重要】
@import は使わないこと!
問題亜点:重くなる、遅くなる の他、今は親テーマがスタイルシートを分けて設定しているため、正しく取得できない。

【スタイルシートを引き継ぐ】
子テーマに「functions.php」を設置し、そこに記述することで、親テーマのスタイルを引き継ぐ。

【functions.php】

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

上記で、スタイルシートを引き継ぐ設定となる。が、エラーでログインできなくなるテーマもあった。
その時は、下記を使用した。

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

【functions.phpの注意点】
親テーマのfunctions.php と記述がダブらないようにすること。
他のファイルと違い、functions.phpは、同一記述があるとエラーが起こり、最悪、ログインできなくなる。
funcions.php を変更する際は、必ずバックアップを取ること!!

参考ページ:http://webhost.glyco-globe.com/wp-child-theme-%E5%AD%90%E3%83%86%E3%83%BC%E3%83%9E/