A default WordPress configuration makes its version number publicly visible in your site’s source code. It looks like a minor detail, but for automated scanners it is a ready answer to the question of whether your site is worth attacking.
In this guide I will show you why you should hide your WordPress version, how to do it step by step with code or plugins, and what this method will not do for you.
The main threat: how attackers exploit the version number
Hiding the version is a small step that takes your site off the lists built by automated scanners. It works on the principle of “security through obscurity”: it does not protect you on its own, but it is one layer of defence.
Attackers use automated bots to scan thousands of websites for specific, outdated WordPress versions with known security vulnerabilities.
Example of an attack: Say WordPress version 6.x.y has a critical security flaw that is fixed in the next release. An attacker could:
- Use a script to find all sites that declare version
6.x.yin their source code. - Launch an automated attack that exploits this specific vulnerability on all of them.
If your version number is hidden, your site will not end up on such a list, which lowers the risk of a mass, automated attack.
Where does WordPress reveal its version?
Before I get to the solutions, here is where this information appears:
- The
generatormeta tag: the<head>section of your site contains a line like this:<meta name="generator" content="WordPress 6.x.y" />. ver=parameters: the URLs of CSS and JavaScript files that ship with WordPress core get the version number appended, e.g./wp-includes/css/dist/block-library/style.min.css?ver=6.x.y. The same goes for thewp-login.phplogin page.- RSS and Atom feeds: the
<generator>tag in your feed (/feed/) contains a URL such ashttps://wordpress.org/?v=6.x.y. - Other XML files: the OPML link list (
/wp-links-opml.php) and the content export file include a generator comment with the version.
Method 1: a small code plugin (recommended)
This is the cleanest method: you do not install a plugin from the repository, and the code will not disappear when you change or update your theme. You upload a single file to the wp-content/mu-plugins/ directory (must-use plugins). WordPress loads it automatically, it cannot be switched off by accident in the admin panel, and it does not depend on your theme.
Why not use the file editor in the admin panel?
Many guides tell you to paste the code into Appearance > Theme File Editor. I do not recommend it, for two reasons:
- The editor is often disabled. A well-secured site has
define('DISALLOW_FILE_EDIT', true);inwp-config.php, because an in-browser file editor is a ready-made tool for anyone who takes over an administrator account. - A syntax error takes the site down. A missing semicolon in
functions.phpends in the “white screen of death”, the admin panel stops working too, and you have to reach for FTP anyway.
Step by step: how to add the code
- Make a backup of your site, or at least of the
wp-contentdirectory. - Connect to your server via FTP/SFTP or the file manager in your hosting panel.
- Open the
wp-contentdirectory. If there is nomu-pluginsfolder in it, create one. - Create a file called
hide-wordpress-version.phpin it and paste the code below. - Open your site, clear the cache and check the source code (see below for how).
Complete code
<?php
/**
* Plugin Name: Hide WordPress version
* Description: Removes the WordPress version number from the page source, RSS feeds and CSS/JS URLs.
*/
// Generator meta tag in <head>, RSS/Atom feeds, the OPML list and the export file.
remove_action('wp_head', 'wp_generator');
add_filter('the_generator', '__return_empty_string');
/**
* Replaces ?ver=<WordPress version> with a hash that does not reveal the version.
*
* The hash changes with every WordPress update, so browsers still fetch the new files.
* Plugin and theme versions are left alone for the same reason.
*/
function uper_hide_wp_version_in_url($src) {
static $wp_version = null;
static $hashed_version = null;
if ($wp_version === null) {
$wp_version = get_bloginfo('version');
$hashed_version = substr(wp_hash($wp_version), 0, 8);
}
parse_str((string) wp_parse_url($src, PHP_URL_QUERY), $args);
if (isset($args['ver']) && $args['ver'] === $wp_version) {
$src = add_query_arg('ver', $hashed_version, $src);
}
return $src;
}
add_filter('style_loader_src', 'uper_hide_wp_version_in_url');
add_filter('script_loader_src', 'uper_hide_wp_version_in_url');
Why doesn’t the code simply strip the ver parameter from every file, like many older guides do? Because that parameter is what busts the cache. When a plugin is updated, its ver= changes and the browser knows it has to download the new file. Without it, visitors can keep getting old CSS or JavaScript for days, which means a broken layout or script errors. That is why the code only touches URLs where ver= equals the WordPress version, and instead of removing it, it puts in a hash: different after every update, but without the version number.
Prefer your theme’s functions.php? The same code works in the functions.php of a child theme (without the opening <?php line and the plugin header). Do not paste it into the parent theme, because it will be lost on the next theme update.
How to check that it works
Open your site in a private window, press Ctrl+U (view source) and search (Ctrl+F) for your version number, e.g. 6.8. Check yourdomain.com/feed/ as well. If the number still shows up, see the questions at the end of this article.
Method 2: use security plugins (for beginners)
If you are not comfortable working with files on the server, you can use plugins that will do the job for you. They usually add other protections too.
- WP Hide & Security Enhancer: a plugin specialised in hiding default WordPress paths and information.
- Wordfence Security: one of the most popular all-in-one security suites. Mainly a firewall and malware scanner, but it also has hardening options.
- Sucuri Security: another popular plugin whose “Hardening” section lets you disable, among other things, the file editor and access to selected files.
Check the settings of the plugin you choose to see whether it also hides ver= parameters, and how. If it strips them from every file, you may run into the stale cache problem described above.
Also keep in mind that every extra plugin is more code on your server. How risky that can be was shown by the backdoor hidden in 31 WordPress plugins.
Limitations: what hiding the version will NOT give you
“Security through obscurity” has its limits. A determined attacker can still work out your WordPress version with high probability, for example by:
- comparing the contents of core JavaScript and CSS files (every release ships slightly different files, and scanning tools have ready-made databases of their checksums),
- looking at the versions of libraries bundled with core, such as jQuery, whose
ver=the code deliberately leaves alone, - checking for changes in the HTML structure that are characteristic of specific releases,
- reading the
readme.htmlfile in the root directory: it no longer contains the version number, but its PHP and MySQL requirements narrow down the range of releases. You can simply delete it (it comes back with every update) or block access to it in your server configuration.
Hiding the version protects against mass, automated attacks, but it does not replace proper security: restricting access to the admin panel, HTTP security headers and backups kept off the server.
Summary: updates are your absolute priority
Hiding your WordPress version is a simple step that makes life harder for automated bots. However, remember that no hiding technique can replace the most important security rule: regular updates.
Keep the WordPress core, plugins and themes on the latest stable versions. It is the updates that contain fixes for critical vulnerabilities.
If your WordPress has already been hacked, slowed down or broken by an update, I fix that for a living. See WordPress rescue at spoko.space: audits, emergency repairs, speed-ups and monthly care at fixed prices.
Frequently Asked Questions
Will hiding the WordPress version affect the functionality of my site?
No. The code in this article only removes metadata that is not needed to display the site, and it replaces the ver= parameter with a hash instead of removing it, so browsers still fetch the new files after an update. Caching problems can appear with solutions that strip ver= from every file.
Is this enough to make my site 100% secure?
Absolutely not. This is just one of many steps in securing a site (so-called "hardening"). The key elements are regular updates, strong passwords, restricting access to the admin panel and limiting login attempts, a firewall, backups kept off the server and regular malware scanning.
After adding the code, the version is still visible. Why?
The most common reason is caching. Clear your site cache (e.g. in a plugin like WP Super Cache, W3 Total Cache or LiteSpeed Cache), the server-level or CDN cache (e.g. Cloudflare) and your browser cache. Also check that the file is directly in wp-content/mu-plugins (not in a subfolder) and that it starts with
Comments