I am registering my sidebars as follows:
$sidebars = array (
'sidebar-10' => 'Main Sidebar',
'sidebar-11' => 'Homepage Area One',
'sidebar-12' => 'Homepage Area Two',
'sidebar-13' => 'Homepage Area Three',
'sidebar-14' => 'Homepage Area Four',
'sidebar-15' => 'Footer Area One',
'sidebar-16' => 'Footer Area Two',
'sidebar-17' => 'Footer Area Three',
'sidebar-18' => 'Footer Area Four',
'sidebar-19' => 'After first post area',
'sidebar-20' => 'Below header area',
);
foreach ( $sidebars as $sidebar ) {
register_sidebar(
array (
'name' => __( $sidebar, 'pietergoosen' ),
'id' => $sidebar,
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
));
}
Main Sidebar
is the name of my widget. I need to set sidebar-10
as the widget id. The same with the rest as in my array.
Any suggestions solving this
You just need to use the alternate syntax for foreach. From the php manual:
For your example: