子テーマディレクトリ作成
style.css作成
functions.php作成
子テーマ有効化
参考記事
子テーマディレクトリ作成
# mkdir /var/www/html/example.com/wp/wp-content/themes/example-child
style.css作成
# vim /var/www/html/example.com/wp/wp-content/themes/example-child/style.css
/*
Theme Name: example-child
Theme URI: http://example.com/example-child/
Description: example-child Theme
Author: hoge
Author URI: http://example.com
Template: <親テーマ名>
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: example-child
*/
functions.php作成
# vim /var/www/html/example.com/wp/wp-content/themes/example-child/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' );
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array('parent-style')
);
}
?>
子テーマ有効化
WordPressダッシュボード > 外観 > テーマ
example-child
というテーマがあれば有効化
参考記事
https://www.webcreatorbox.com/tech/wordpress-child-theme