How to remove WordPress version from blog source code
Categorized as Wordpress
To add some security to your WordPress installation, you can hide the version from the source code.
No plugins needed, just add some extra code at the end of your theme functions.php
file. See the code below.
function remove_version_info() {
return '';
}
add_filter('the_generator', 'remove_version_info');
function remove_version_from_style_js( $src ) {
if ( strpos( $src, 'ver=' . get_bloginfo( 'version' ) ) )
$src = remove_query_arg( 'ver', $src );
return $src;
}
add_filter( 'style_loader_src', 'remove_version_from_style_js');
add_filter( 'script_loader_src', 'remove_version_from_style_js');
(Optional). You can also completely remove the query parameters from your css or javascript files:
// Remove query string from css files
function remove_query_string_from_css_files( $src ) {
if( strpos( $src, '?ver=' ) )
$src = remove_query_arg( 'ver', $src );
return $src;
}
add_filter( 'style_loader_src', 'remove_query_string_from_css_files', 10, 2 );