子テーマ
テーマ(theme)を直接いじるとテーマの更新時にリセットさせるので,子テーマ(child theme)を作っていじる方法について手順を示す.
1) 子テーマ用フォルダを作る
例:wp-content/themes/twentytwentyfive_child/
2) style.css を作る(必須)
wp-content/themes/twentytwentyfive_child/style.css
/*
Theme Name: Twenty TwentyFive_Child
Template: twentytwentyfive
Version: 1.0.0
*/
3) (ブロックテーマ推奨)theme.json を作る
wp-content/themes/twentytwentyfive_child/theme.json
親テーマのそのままでよいなら不要.
{
"version": 2,
"styles": {
"typography": { "fontSize": "16px" }
}
}
4) 管理画面で有効化
管理画面 → 外観 → テーマ → 子テーマを 有効化
【注意点・例外】
- FSE(ブロック)テーマの場合:昔の“functions.phpでCSSをenqueueして…”より、まず
theme.json/ ブロックエディタ側での調整が中心になります(必要なら functions.php も使えます)。 - 親テーマのフォルダ丸ごとコピーは不要です(最小ファイルだけでOK)。余計なコピーは更新追従が面倒になりがちです。
- もし「管理画面から作りたい」なら、ブロックテーマ向けに Create Block Theme 系プラグインを使う流れもあります(ただし環境によって挙動差が出るので、運用ルールが厳しい場合は専門家に確認が必要)。
【出典】
- WordPress Developer Resources(Theme Handbook)Child Themes
- WordPress Developer Resources
theme.json解説 - WordPress.com Support(子テーマ作成、Template指定)
- (参考)ブロックテーマの子テーマ作成(Create Block Theme等の言及)
以上
