$widgets ) { if ( is_array( $widgets ) ) { foreach ( $widgets as $index => $widget_id ) { if ( $widget_id== 'sidebar-navigation' ) { $sidebars[ $sidebar_id ][ $index ] = $widget_id . '-1'; $changed = true; break; } } } if($changed) { break; } } if ( $changed ) { update_option( 'sidebars_widgets', $sidebars ); }