Turn off autoloading for big options that WordPress loads on every request but rarely needs.
add_action( 'admin_init', function (): void {
// Run once. Remove this line's option to run again.
if ( get_option( 'nahnu_autoload_fixed' ) ) {
return;
}
// Option names from Site Health or the query in the notes.
$options = [
'some_plugin_big_cache',
'old_plugin_settings',
];
foreach ( $options as $name ) {
if ( false !== get_option( $name ) ) {
wp_set_option_autoload( $name, false );
}
}
update_option( 'nahnu_autoload_fixed', 1, false );
} );
Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.
WordPress loads every “autoloaded” option on every page request. Plugins sometimes store large caches or old data with autoload on, so every page pays the cost. Since WordPress 6.6, Site Health warns when autoloaded options get too big. This snippet switches autoloading off for the ones you name.
wp_set_option_autoload() changes an option’s autoload flag without changing its value. The option still works; WordPress loads it the first time something asks for it instead of on every request.
The snippet runs once on admin_init and records that it ran, so it doesn’t touch the database on every admin page.
wp db query "SELECT option_name, LENGTH(option_value) AS size FROM wp_options WHERE autoload IN ('yes','on','auto-on') ORDER BY size DESC LIMIT 20".siteurl, active_plugins or cron.Load wp-admin once, then check the option’s autoload value in the database. It should now be off, and Site Health’s autoload warning should shrink.