I've got the following functions as in this pastebin in a child theme:
This functions creates a drop down box from where you can choose a sidebar for use on a specific page. Everything works fine after a lot of sweat. My only problem is the
$wp_registered_sidebars
function in the following piece of code
foreach($wp_registered_sidebars as $sidebar_id => $sidebar)
{
$output .= "<option";
if($sidebar_id == $val)
$output .= " selected='selected'";
$output .= " value='".$sidebar_id."'>".$sidebar['name']."</option>";
}
$output .= "</select>";
echo $output;
This function lists all the available sidebars of the theme, and this is what I don't want. I only want the drop down box to display the sidebars in the
$dynamic_widget_areas
array. If I replace
$wp_registered_sidebars
with
$dynamic_widget_areas
I get the following errors:
Notice: Undefined variable: dynamic_widget_area ...etc
and
Warning: Invalid argument supplied for foreach() ...etc
What is the correct way to display only certain sidebars.