Blog Detail

image

The Right Way to Remove WordPress Version Number

Do you want to remove the WordPress version number from your website?

Many believe that removing the WordPress version number from your website’s source code can prevent some common online attacks.

In this article, we’ll show you how to easily remove WordPress version number the right way.

To remove versions from WordPress plugins without using a plugin, you can add the following code to your theme's functions.php file:

// Remove version from scripts and stylesheets 

function remove_plugin_versions( $src ) { 

    if ( strpos( $src, '?ver=' ) ) { 

        $src = remove_query_arg( 'ver', $src ); 

    } 

return $src; 

add_filter( 'script_loader_src', 'remove_plugin_versions' ); 

add_filter( 'style_loader_src', 'remove_plugin_versions' );


This code will remove the version parameter from the URLs of all scripts and stylesheets loaded by WordPress, effectively removing the version numbers from the plugin files.

It's always a good idea to make a backup of your theme's functions.php file before making any changes, just in case.