子テーマは、子テーマディレクトリと2つのファイル(style.css と functions.php) から構成される。 1.wp-content/themes ディレクトリ下に子テーマディレクトリを作成(子テーマディレクトリの名前には最後に '(親テーマ名)_child' を付けるとわかりやすい) 2.子テーマディレクトリ下にstyle.cssを作成(Theme NameとTemplateのみでOK) 3.子テーマディレクトリ下にfunctions.phpを作成(親テーマのスタイルシートをキューに入れる処理を記述)
/*
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
*/
<?php
///////////////////////////////////////
// 親テーマのスタイルシートをキューに入れる
///////////////////////////////////////
add_action( 'wp_enqueue_scripts', function () {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
});
?>