Missing argument 2 for a custom function widgets_init

I am using a theme_mod string from customizer to generate custom sidebar, but it is called from another function. This is my code:

function call_sidebar_function() {

if ( get_theme_mod( ‘enable_sidebar’ ) ) {
$name = “mySidebarName”;
$numberOfSidebars = get_theme_mod(‘number_of_sidebars’);
generate_sidebars($name, $numberOfSidebars);
}
}

function generate_sidebars($name, $numberOfSidebars) {
$i = 1;
foreach ($numberOfSidebars as $sidebar) {
register_sidebar(
array(
‘name’ => $name.$i,
‘id’ => $name.$i,
)
);
$i++;
}
}
add_action( ‘widgets_init’, ‘generate_sidebars’ );

Read more here:: Missing argument 2 for a custom function widgets_init

Leave a Reply

Your email address will not be published. Required fields are marked *