Register multiple sidebars

You just need to use the alternate syntax for foreach. From the php manual:

The foreach construct provides an easy way to iterate over arrays.
foreach works only on arrays and objects, and will issue an error when
you try to use it on a variable with a different data type or an
uninitialized variable. There are two syntaxes:

foreach (array_expression as $value)
    statement
foreach (array_expression as $key => $value)
    statement

For your example:

foreach ( $sidebars as $id => $sidebar) {
register_sidebar(
    array (
            'name'          => __( $sidebar, 'pietergoosen' ),
            'id'            => $id,
            'before_widget' => '<aside id="%1$s" class="widget %2$s">',
            'after_widget'  => '</aside>',
            'before_title'  => '<h3 class="widget-title">',
            'after_title'   => '</h3>',
    ));
}

Leave a Comment