I want to remove the WordPress version from my Source Code. To achieve this, I have placed the following code in my functions.php file:

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

This code has worked for me in the past but for some reason, the WordPress version is still appearing in my Source Code.

I have deactivated my Plugins but still with no success. Nor has trailing the internet for any updates on new codes etc.

Has anyone else got this problem or know of where may be going wrong?

2 Answers 2


Your code works for me in version 4.7.2 with 2016 theme, but a slightly simpler version is to remove the action entirely rather than filter the output:

remove_action( 'wp_head', 'wp_generator' );
  • Your suggestion does not work for me neither. I am not sure if this is related but I cannot seem to 'hook' into my website through my functions.php file too. I thought there may be something wrong with my functions.php file but as soon as I delete the file, it affects my website so the file is 'active'.
    – Craig
    Feb 20, 2017 at 2:26

I have figured out the problem!

For anyone reading this, my code does work perfectly fine. The issue lied within my functions.php file.

Rather than have the following in my file:

function theme_name_script_enqueue() {

wp_enqueue_style( 'wpb-fa', get_template_directory_uri() . '/fonts/css/font-awesome.min.css', array(), '1.0', true );
add_action( 'wp_enqueue_scripts', 'theme_name_script_enqueue' );

I had ...

function theme_name_script_enqueue() {

wp_enqueue_style( 'wpb-fa', get_template_directory_uri() . '/fonts/css/font-awesome.min.css' );
add_action( 'wp_enqueue_scripts', 'theme_name_script_enqueue' );

Note that I was missing , array(), '1.0', true

Once the above was inserted, all worked perfectly fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.