In a case like this, you’re probably going to need to check the conditions in dynamic_sidebar
to find out what is not happening.
if (isset($_GET['debugsidebar'])) {add_action('init', 'debug_sidebar');}
function debug_sidebar() {
$id = $_GET['debugsidebar'];
$sidebarswidgets = get_option('sidebars_widgets');
if (is_active_sidebar($id)) {$status = " Active";} else {$status = "Inactive";}
echo "Sidebar ID: ".$id." (".$status.")<br>";
if (array_key_exists($id, $sidebarswidgets)) {
$found = "Sidebar Found";
if (is_array($sidebarswidgets[$id])) {
$widgets = count($sidebarswidgets[$id])." Widgets Found";
} else {$widgets = "Widget Array not Found!";}
echo $found."<br".$widgets."<br>";
else {echo "Sidebar Not Found<br>";}
echo "<br>All Sidebars Widgets: ".print_r($sidebarswidgets,true)."<br>";
exit;
}
Which you put in your theme functions.php
and then can check via http://example.com/?debugsidebar=my_sidebar
There is a small difference in the bugout checks is is_active_sidebar
and dynamic_sidebar
From is_active_sidebar
function:
! empty( $sidebars_widgets[ $index ] );
From dynamic_sidebar
function:
if ( empty( $wp_registered_sidebars[ $index ] ) || empty( $sidebars_widgets[ $index ] ) || ! is_array( $sidebars_widgets[ $index ] ) ) {
Since the middle condition is the same, this means that either the sidebar is not being registered correctly (unlikely as that seems fine) – but more likely, the data for that key is not an array of widgets. You will find out from running the debug function.
It may possibly show you a mismatch or corrupt data in the sidebars_widgets
option value (If needs be you can that check against a value from you wp_options
table backup from when it was working.)