Removing wordpress version from source code

Featured Video Play Icon

WordPress Tutorial: In simple steps, going to show you how to add remove WordPress version from source code. The following codes are tested by using WordPress Child Theme.

Step 1: Open functions.php file ( Assuming you are using WordPress child theme)

Step 2: Add this below code

/*==========================================
Remove version from head
===========================================*/
remove_action('wp_head', 'wp_generator');
/*==========================================
Remove version from rss
===========================================*/
function remove_feed_generator() {
return '';
}
add_filter('the_generator', 'remove_feed_generator');
/*==========================================
Remove version from scripts and styles
===========================================*/
function remove_version_scripts_styles($src) {
    if (strpos($src, 'ver=')) {
        $src = remove_query_arg('ver', $src);
    }
    return $src;
}
add_filter('style_loader_src', 'remove_version_scripts_styles', 9999);
add_filter('script_loader_src', 'remove_version_scripts_styles', 9999);

Step 3: Save it and you are done.