WordPressをマルチブログで利用する場合に、子サイトのテーマをあらかじめ設定しておく方法を紹介します。
親サイトの functions.php に下記の記述をするだけです。
function default_theme_setting()
{
update_option('template', 'theme_name');
update_option('stylesheet', 'theme_name');
update_option('current_theme', 'Theme Name');
}
add_action('populate_options', 'default_theme_setting');
theme_name となっている箇所は、テーマのディレクトリ名を入れます。
Theme Name となっている箇所は、テーマの名称を入れておきます。
子テーマを指定する方法
上記の設定で、あるテーマの子テーマを設定しようとすると上手くいきません。
これは、下記の記述にすることで対応可能です。
function default_theme_setting()
{
update_option('template', 'parent_theme_name');
update_option('stylesheet', 'child_theme_name');
update_option('current_theme', 'Child Theme Name');
}
add_action('populate_options', 'default_theme_setting');
parent_theme_name は親テーマのディレクトリ名を入れます。
child_theme_name は子テーマのディレクトリ名を入れます。
要は stylesheet というオプションに子テーマ名を設定し、template というオプションには親テーマを設定しておかなきゃイカンよ、ということです。