Useful Code Snippets for WordPress 6.1

Useful Code Snippets WordPress 6.1

Heads up: This page may include affiliate links. Read the full disclosure.

WordPress 6.1 is scheduled to be released on the 1st of November and contains many feature improvements.

WordPress 6.1

Database queries made using WP_Query will now be cached by default in WordPress 6.1.

To disable caching globally on query improvements (extreme case), use this code snippet;

function disable_caching( $wp_query ) {
   $wp_query->query_vars['cache_results'] = false;
}

add_action( 'parse_query', 'disable_caching' );

Also, in the WordPress 6.1 release, new cache checks are being added to the site health, and a new filter was added so that you can suggest persistent object caching and change the link in the check for caching in site health.

In the site health report in wp-admin opt-in to suggest object caching;

add_filter( 'site_status_should_suggest_persistent_object_cache', '__return_true' );

To change the WordPress URL link to your link for a client;

add_filter( 'site_status_persistent_object_cache_url', function() {
    return 'https://sitedomain.com/optimization/persistent-object-cache';
} );

To disable new user email notifications to admin users, they can be disabled using the new filter added in WordPress 6.1.

add_filter( 'wp_send_new_user_notification_to_admin', '__return_false' ); 

To modify the lost password link HTML link wording, the new filter can be used in WordPress 6.1.

apply_filters( 'lost_password_html_link', $html_link );

(The WP.org docs will be updated soon for the correct code snippet)

You can insert these code snippets to multiple WordPress sites at once using the MainWP Code Snippet Extension.

Useful Links

Looking for something?

Privacy laws apply to businesses that collect personal information. Since no personal information is collected by the MainWP plugins, no privacy laws apply to the MainWP plugins. This includes GDPR, UK DPA 2018, PIPEDA, Australia Privacy Act 1988, LGPD, PIPL, and other privacy laws.
Donata Stroink-Skillrud
Donata Stroink-Skillrud
President of Agency Attorneys

Your Download Is Just One Click Away

…or just download the plugin.

By entering your email, you agree to our Terms of Service and Privacy Policy.