March 24, 2021
In the past I’ve manually changed the content of the jquery file (I know, bad bad bad), or used a plugin to make this editable for me (also, bad bad bad). This snippet helps avoid those two methods and lets the edit occur within your theme.
Place in functions.php:
function replace_core_jquery_version() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', "https://code.jquery.com/jquery.min.js", array(), '3.1.1' ); // change to any version you want, you can also set to a local jquery file in your theme
}
add_action( 'wp_enqueue_scripts', 'replace_core_jquery_version' );
The above affects the front end only. But you can also add this line in order to have your preferred jQuery version affect the backend as well. This is highly not recommended as it can affect the way the admin interface functions, so proceed with caution.
add_action( 'admin_enqueue_scripts', 'replace_core_jquery_version' );