diff --git a/src/wp-includes/widgets.php b/src/wp-includes/widgets.php index 7a3cb5673a4fa..f991921c9e4de 100644 --- a/src/wp-includes/widgets.php +++ b/src/wp-includes/widgets.php @@ -703,10 +703,12 @@ function dynamic_sidebar( $index = 1 ) { $index = "sidebar-$index"; } else { $index = sanitize_title( $index ); - foreach ( (array) $wp_registered_sidebars as $key => $value ) { - if ( sanitize_title( $value['name'] ) === $index ) { - $index = $key; - break; + if ( empty( $wp_registered_sidebars[ $index ] ) ) { + foreach ( (array) $wp_registered_sidebars as $key => $value ) { + if ( sanitize_title( $value['name'] ) === $index ) { + $index = $key; + break; + } } } }