1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

WordPress子テーマ作成

Last updated at Posted at 2021-09-23

子テーマディレクトリ作成
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

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?