Print this Post

How to remove WordPress version from head section

For security reasons, it is a good practice to remove the automatically generated WordPress version numbers from the head section of the page.

Here is a custom function to remove those unwanted WordPress version information from all pages. You can add this code to your (child) theme’s functions.php file.

function wordpress_version_remove() {
return '';
add_filter('the_generator', 'wordpress_version_remove');

Note: If your child theme is empty, place the code in between <?php and ?>. i.e

function wordpress_version_remove() {
return '';
add_filter('the_generator', 'wordpress_version_remove');

Short Link:

About the author

Prasanna SP

Student | WordPress Dev | Tech Blogger | Interested in GNU/Linux, FOSS, PHP, Drupal, WordPress, Ethical hacking, Photography, Painting, Literature etc..

Permanent link to this article: http://www.prasannasp.net/how-to-remove-wordpress-version-from-head-section/


Skip to comment form

  1. PKP

    Hi Prasanna,

    Very useful information here. Thanks.

    A question …

    Where exactly we should put the following lines?

    function wordpress_version_remove() {
    return '';
    add_filter('the_generator', 'wordpress_version_remove');



    1. Prasanna SP

      Hi PKP, you can add this function in any of your active plugin or in your theme’s functions.php file. But, best move is to add this in your child theme’s functions.php file.

      1. PKP

        Thanks Prsanna.
        Will go through your post about child theme and then make changes.


  2. Ken

    Just out of curiosity, what are those security reasons?

    1. Prasanna SP

      Hi Ken, the reason to remove WordPress version is that, there are some security vulnerabilities in the previous versions of WP. As you know, not everybody updates their wordpress as a new version comes out. So, if somebody is using an older version and a cracker gets to know the version, it becomes easy for him to compromise the site. So, it is recommended to remove the version details of wordpress and plugins from the page source.

  3. Solution Epilation

    Hello Parsanna,

    Thanks for this tip. My boss also wants me to remove the “Powered by WP and the Graphene theme” in the footer : I don’t want to just hide it with CSS, I want to remove the html. Is that possible with a likewise custom function ?

    @Ken : the security issue is that if a security fail is discovered for a particular version of WP, robots can crawl the web to identify websites using this version, hence allowing them to hack the site.

    1. Ken

      That makes sense. Thanks! I’ll be making this change soon.

    2. Prasanna SP

      Yes, you can remove graphene_developer action using a child theme. See this page for more information on removing actions – http://codex.wordpress.org/Function_Reference/remove_action

      1. Solution Epilation

        Thanks Prasanna for the answer. However I’m not very knowledgeable on code and don’t know what’s an action hook. Tried looking it up but cannot find a clear answer. Could you please tell me what they are ?

        Could you also please give me the code in the case of the credits ? This would be very helpful and will serve as an example, as I also want to remove the img in the header in a similar fashion.

        Thanks !

  4. Ron

    Found this one-line code on digwp. Thought I’d share it here 🙂

    remove_action('wp_head', 'wp_generator');

    1. Prasanna SP

      Hi Ron! The above one line code removes WordPress version from website head only. But my code removes it from RSS feed as well.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please put your code snippet between <code> and </code>. Comment moderation is in use. Please do not submit your comment twice -- it will appear shortly.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.