看来我找到答案了here.这是我在我的孩子主题中使用的代码的工作版本functions.php
文件
function my_widgets_init() {
register_sidebar( array(
\'name\' => esc_html__( \'Default Sidebar\', \'codilight-lite\' ),
\'id\' => \'sidebar-1\',
\'description\' => \'\',
\'before_widget\' => \'<aside id="%1$s" class="widget %2$s">\',
\'after_widget\' => \'</aside>\',
\'before_title\' => \'<h2 class="widget-title"><span>\',
\'after_title\' => \'</span></h2>\',
) );
// Homepage Template
register_sidebar( array(
\'name\' => esc_html__( \'Home 1\', \'codilight-lite\' ),
\'id\' => \'home-1\',
\'description\' => \'\',
\'before_widget\' => \'<aside id="%1$s" class="home-widget %2$s">\',
\'after_widget\' => \'</aside>\',
\'before_title\' => \'<h2 class="widget-title"><span>\',
\'after_title\' => \'</span></h2>\',
) );
register_sidebar( array(
\'name\' => esc_html__( \'Home 2\', \'codilight-lite\' ),
\'id\' => \'home-2\',
\'description\' => \'\',
\'before_widget\' => \'<aside id="%1$s" class="home-widget %2$s">\',
\'after_widget\' => \'</aside>\',
\'before_title\' => \'<h2 class="widget-title"><span>\',
\'after_title\' => \'</span></h2>\',
) );
register_sidebar( array(
\'name\' => esc_html__( \'Home 3\', \'codilight-lite\' ),
\'id\' => \'home-3\',
\'description\' => \'\',
\'before_widget\' => \'<aside id="%1$s" class="home-widget %2$s">\',
\'after_widget\' => \'</aside>\',
\'before_title\' => \'<h2 class="widget-title"><span>\',
\'after_title\' => \'</span></h2>\',
) );
register_sidebar( array(
\'name\' => esc_html__( \'Home 4\', \'codilight-lite\' ),
\'id\' => \'home-4\',
\'description\' => \'\',
\'before_widget\' => \'<aside id="%1$s" class="home-widget %2$s">\',
\'after_widget\' => \'</aside>\',
\'before_title\' => \'<h1 class="widget-title"><span>\',
\'after_title\' => \'</span></h1>\',
) );
}
add_action(\'after_setup_theme\',\'remove_parent_widgets\');
function remove_parent_widgets() {
remove_action( \'widgets_init\', \'codilight_lite_widgets_init\' );
}
add_action( \'after_setup_theme\', \'my_widgets_init\' );