I have a child theme that does add some additional widgets but that code is in the same format as in the theme functions.php file:
/* Find out which sidebars are active */
$num_of_sidebars = (int) is_active_sidebar( 'first-footer-widget-area' ) + (int) is_active_sidebar( 'second-footer-widget-area' ) + (int) is_active_sidebar( 'third-footer-widget-area' ) + (int) is_active_sidebar( 'fourth-footer-widget-area' ) + (int) is_active_sidebar( 'sidebar-copyright' );
/**
* Register more widget areas.
*
* @link https://code.tutsplus.com/tutorials/dynamically-adding-four-footer-widget-areas--cms-22168
*/
// First footer widget area, located in the footer. Empty by default.
register_sidebar( array(
'name' => __( 'First Footer Widget Area', 'twentyseventeen' ),
'id' => 'first-footer-widget-area',
'description' => __( 'The first footer widget area', 'twentyseventeen' ),
'before_widget' => '<div id="%1$s" class="widget-container %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
// Second Footer Widget Area, located in the footer. Empty by default.
register_sidebar( array(
'name' => __( 'Second Footer Widget Area', 'twentyseventeen' ),
'id' => 'second-footer-widget-area',
'description' => __( 'The second footer widget area', 'twentyseventeen' ),
'before_widget' => '<div id="%1$s" class="widget-container %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
// Third Footer Widget Area, located in the footer. Empty by default.
register_sidebar( array(
'name' => __( 'Third Footer Widget Area', 'twentyseventeen' ),
'id' => 'third-footer-widget-area',
'description' => __( 'The third footer widget area', 'twentyseventeen' ),
'before_widget' => '<div id="%1$s" class="widget-container %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
// Fourth Footer Widget Area, located in the footer. Empty by default.
register_sidebar( array(
'name' => __( 'Fourth Footer Widget Area', 'twentyseventeen' ),
'id' => 'fourth-footer-widget-area',
'description' => __( 'The fourth footer widget area', 'twentyseventeen' ),
'before_widget' => '<div id="%1$s" class="widget-container %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
// Copyright Footer Widget Area, located in the footer. Empty by default.
register_sidebar( array(
'name' => __( 'Copyright area', 'twentyseventeen' ),
'id' => 'sidebar-copyright',
'description' => __( 'Place a text widget in this area and add your copyright text', 'twentyseventeen' ),
'before_widget' => '<div id="%1$s" class="widget-container %2$s">',
'after_widget' => '</div>',
'before_title' => '',
'after_title' => '',
) );
function get_my_widget_title() {
$my_widget_title = 'Copyright';
return null;
}
// Register sidebars by running twentyseventeen_widgets_init() on the widgets_init hook.
add_action( 'widgets_init', 'twentyseventeen_widgets_init' );