How To Remove WordPress Version Number

Aug 29, 2013, by admin

 How To Remove WordPress Version Number

By default WordPress leaves it’s footprints on your site for the sake of tracking. That is how we know that WordPress is the World’s largest Blogging platform. But sometimes this footprint might be a security leak on your site if you are not running the most updated version of WordPress. Because you are providing the hacker with the useful information by telling them which version you are running.

If you are not using latest WordPress version, the hackers can target the known vulnerabilities in that version to hack your site.
You can check all the Vulnerability in “Open Sourced Vulnerability Database” founded at http://osvdb.org/

There are various ways that can be used to remove this information and some of them were given below

Add these following codes to in your functions.php file of your theme according to your requirements.

<?php

/* Function to hide WordPress version number
*  from the head section and RSS feeds on your site.  
*/

function my_remove_version_info() {
     return ”;
}
add_filter(‘the_generator’, ‘my_remove_version_info’);
?>

Remove the “ver” parameter from all enqueued CSS and JS files in the page

<?php

/* remove wp version param from any enqueued scripts (css/js)*/
function vc_remove_wp_ver_css_js( $src ) {
    if ( strpos( $src, ‘ver=’ ) )
        $src = remove_query_arg( ‘ver’, $src );
    return $src;
}
add_filter( ‘style_loader_src’, ‘vc_remove_wp_ver_css_js’, 9999 );
add_filter( ‘script_loader_src’, ‘vc_remove_wp_ver_css_js’, 9999 );
?>

Remove only the “ver” parameters which have WordPress version number from all enqueued CSS and JS files in your page.

<?php

/* remove wp version param from any enqueued scripts (css/js)*/
function vc_remove_wp_ver_css_js( $src ) {
    if ( strpos( $src, ‘ver=’ . get_bloginfo( ‘version’ ) ) )
        $src = remove_query_arg( ‘ver’, $src );
    return $src;
}
add_filter( ‘style_loader_src’, ‘vc_remove_wp_ver_css_js’, 9999 );
add_filter( ‘script_loader_src’, ‘vc_remove_wp_ver_css_js’, 9999 );
?>

And i hope this will be the best way to Remove WordPress Version Number

In order for you to completely remove your WordPress version number from both your head file and RSS feeds, you will need to add the following function to your functions.php file:
1    function Bugtreat_remove_version() {
2    return ”;
3    }
4    add_filter(‘the_generator’, ‘Bugtreat_remove_version’);

By adding this version, you will remove the WordPress version number from all different areas on your site. Above is the right way to remove WordPress Version number.

Note: We still recommend that you update to the latest version of WordPress because that is the only guaranteed way to keep your blog protected.