您可以执行类似Genesis子主题的操作,以在激活和切换主题时保存默认主题设置:
//* Theme Setting Defaults
add_filter( \'genesis_theme_settings_defaults\', \'child_theme_defaults\' );
function child_theme_defaults( $defaults ) {
$defaults[\'blog_cat_num\'] = 6;
$defaults[\'content_archive\'] = \'full\';
$defaults[\'content_archive_limit\'] = 150;
$defaults[\'content_archive_thumbnail\'] = 0;
$defaults[\'image_alignment\'] = \'\';
$defaults[\'image_size\'] = \'entry-image\';
$defaults[\'posts_nav\'] = \'prev-next\';
$defaults[\'site_layout\'] = \'full-width-content\';
return $defaults;
}
//* Theme Setup
add_action( \'after_switch_theme\', \'child_theme_setting_defaults\' );
function child_theme_setting_defaults() {
if( function_exists( \'genesis_update_settings\' ) ) {
genesis_update_settings( array(
\'blog_cat_num\' => 6,
\'content_archive\' => \'full\',
\'content_archive_limit\' => 150,
\'content_archive_thumbnail\' => 0,
\'image_alignment\' => \'\',
\'image_size\' => \'entry-image\',
\'posts_nav\' => \'prev-next\',
\'site_layout\' => \'full-width-content\',
) );
} else {
_genesis_update_settings( array(
\'blog_cat_num\' => 6,
\'content_archive\' => \'full\',
\'content_archive_limit\' => 150,
\'content_archive_thumbnail\' => 0,
\'image_alignment\' => \'\',
\'image_size\' => \'entry-image\',
\'posts_nav\' => \'prev-next\',
\'site_layout\' => \'full-width-content\',
) );
显然,您需要修改此代码才能使用主题功能。