利用するWordPressテーマを決めたら「子テーマ」を別途作成します。子テーマとは、選択した既存のWordPressテーマ(親テーマ)の機能とスタイルを継承したテーマです。テーマのカスタマイズは子テーマで行います。
詳しくは、子テーマをご確認ください。
Template: 親テーマのフォルダ名を追記
以上、とても簡単に作成できました。
詳しくは、子テーマをご確認ください。
1. 子テーマのフォルダを作成する。
親テーマ(既存のテーマ)と同じ階層(wp-content/themes)に新しいフォルダを作成します。フォルダ名は「親テーマ名-child」をおすすめします。2. style.cssを作成する。
作成した子テーマのフォルダに「style.css」ファイルを作成し、以下の内容を参考に記述します。
/*
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: 子テーマの名前に変更Template: 親テーマのフォルダ名を追記
3. functions.phpを作成する。
作成した子テーマのフォルダに「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' );
}
4. 子テーマを有効化する。
WordPress > 外観 > テーマ以上、とても簡単に作成できました。