twentytwentythree の子テーマについては不要論も見かけたけれども,とりあえず作ってみる.書籍やネット上の情報をもとに作ってみるも,functions.php の不具合で子テーマに切り替えた途端サイトがエラー吐いてアクセスできなくなったりもしたので,動いたものを掲載する.
- style.css
1 2 3 4 5 | /* Theme Name: Twenty Twenty-Three Child Template: twentytwentythree Version: 1.6 */ |
Version はオリジナルのものを掲載.
- functions.php
1 2 3 4 5 6 7 8 9 10 11 | <?php 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') ); } add_action('wp_enqueue_scripts', 'theme_enqueue_styles'); |
これでテーマを子テーマの Twenty Twenty-Three Child に切り替えてもエラーを吐かなかった.