
Learn how to hide your WordPress site version number using WPCodeBox and a simple snippet!
By default, WordPress displays its version number in the page source and file URLs, which can give hackers clues about potential exploits. To reduce this risk, you can hide the WordPress version number with a simple snippet in WPCodeBox.
First, you’ll remove the generator meta tag that exposes the version in your site’s HTML. Then, you’ll strip the version parameter from core WordPress scripts and styles without affecting plugins or themes, which often rely on version numbers for cache busting and compatibility.
With this approach, your site’s version details stay hidden from the front end, while functionality remains intact. This makes your WordPress site more private and secure in just a few minutes.
Below is the code snippet from the video used to hide WordPress version number:
<?php
add_filter('the_generator','_return_empty_string');
function remove_version_from_assets($src) {
$wp_version = get_bloginfo('version');
if(strpos($src,'ver='.$wp_version) !== false) {
$src = remove_query_arg('ver',$src);
}
return $src;
}
add_filter('style_loader_src','remove_version_from_assets',9999);
add_filter('script_loader_src',' remove_version_from_assets',9999);