Back to Top

Remove WordPress’s Version Number

Previous Post:

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');

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);

All version numbers are now removed and your website/blog is safe from prying eyes ;).

References

  1. http://codex.wordpress.org/Function_Reference/wp_enqueu ... eue_script []

Take Social Sharing to
the Next Level with Monarch!

Take Social Sharing to the Next Level with Monarch!
Print Article Trackback Trackback to this Article   Subscribe to Comments RSS Subscribe to Comments RSS

6 Opinions for Remove WordPress’s Version Number

  1. User's Gravatar
    1
    Ken April 7, 2011 at 4:30 pm – Permalink

    Remember to remove readme.html and license.txt too, as they also contain the version number 😉

    • User's Gravatar
      2
      OddOneOut April 8, 2011 at 5:30 pm – Permalink

      You are right, completely forgot about that. After each update we will have to remove them again, ugh…

      • User's Gravatar
        3
        JonnyDee May 4, 2013 at 9:41 am – Permalink

        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}

  2. User's Gravatar
    4
    Roman Iakoubtchik April 26, 2013 at 3:31 am – Permalink

    Short, Clean code which still works perfectly. Thank you!

  3. User's Gravatar
    5
    JonnyDee May 4, 2013 at 9:43 am – Permalink

    where are these modifications made?

    • User's Gravatar
      6
      Khang Minh May 4, 2013 at 9:09 pm – Permalink

      You can put those modifications in your theme’s functions.php file.

Speak Up Your Mind!

An asterisk (*) indicates a required field and must be filled.




  • Web page and e-mail addresses turn into links automatically.
  • Wrap codes in: <code lang=""></code> or <pre lang="" extra="">
  • Lines and paragraphs break automatically.

Next Post: