Remove WordPress’s Version Number
We all know the fact that WordPress’s version number appear all over our websites/blogs and some might find that annoying, especially users who do not want others to know what versions they are using. Basically, the version number will appear in three public places including your <head> tag, your feeds and your media links (i.e. CSS and JS files that are enqueued by wp_enqueue_{} function1).
It is easy to get rid of all the version numbers in <head> tag and feeds, using less than 4 lines of codes:
- foreach (array('rss2_head', 'commentsrss2_head', 'rss_head', 'rdf_header', 'atom_head', 'comments_atom_head', 'opml_head', 'app_head') as $action)
- remove_action($action, 'the_generator');
- remove_action('wp_head', 'wp_generator');
foreach (array('rss2_head', 'commentsrss2_head', 'rss_head', 'rdf_header', 'atom_head', 'comments_atom_head', 'opml_head', 'app_head') as $action)
remove_action($action, 'the_generator');
remove_action('wp_head', 'wp_generator');For enqueued media files you actually have two options: use your own version number or give the NULL value to the $ver argument, like so:
- // Using your own version number: 1.1.0
- wp_enqueue_style('my-stylesheet', 'url-to-stylesheet', array(), '1.1.0');
- wp_enqueue_script('my-script', 'url-to-script', array(), '1.1.0');
- // Using a NULL value to hide the version number completely
- wp_enqueue_style('my-stylesheet', 'url-to-stylesheet', array(), NULL);
- wp_enqueue_script('my-script', 'url-to-script', array(), NULL);
// Using your own version number: 1.1.0
wp_enqueue_style('my-stylesheet', 'url-to-stylesheet', array(), '1.1.0');
wp_enqueue_script('my-script', 'url-to-script', array(), '1.1.0');
// Using a NULL value to hide the version number completely
wp_enqueue_style('my-stylesheet', 'url-to-stylesheet', array(), NULL);
wp_enqueue_script('my-script', 'url-to-script', array(), NULL);All version numbers are now removed and your website/blog is safe from prying eyes
.









Remember to remove readme.html and license.txt too, as they also contain the version number
You are right, completely forgot about that. After each update we will have to remove them again, ugh…
what!? nothing to add or modify to delete those two files when they appear? What about blank files named the same, chmod to lock them? {me=not a coder}
Short, Clean code which still works perfectly. Thank you!
where are these modifications made?
You can put those modifications in your theme’s functions.php file.