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' );
Related Posts:
- Where does WordPress store version number?
- How to remove the WordPress version from some .css/.js files
- Supporting older WordPress versions in a Plugin/Theme? [closed]
- Disable WP core updates but send email notification
- Getting version number of latest WordPress release
- Remotely identify the version of a WordPress installation?
- How to find out when WordPress version last updated
- Switch from Beta Version to Stable Version
- Where can I get WordPress Version in Dashboard?
- What’s the point of the WP version generator?
- Downloading WordPress: Nightly Build vs. Stable Download
- Removing WordPress version number from included files [duplicate]
- Information about WordPress 4
- When will the 4.3 branch become EOL
- WordPress Version check with PHP
- WordPress updater conflict
- Different versions of WordPress between local and production
- WordPress Update 4.3.1 [closed]
- How to revert back to older WordPress version?
- Any plans for a non backwords compatible WP release? [closed]
- Production Site: Moving from WordPress RC to Final Release Version
- how can i take out the version in my main.css file? [duplicate]
- Why does the WordPress official website show a fake release date?
- How to Fix “Your PHP Installation Appears to Be Missing the MySQL Extension Which Is Required by WordPress” Error
- Automatically determine minimum WordPress version required for a plugin?
- How do I find the version of WordPress I have from the source code?
- Why are there updates for obsolete WordPress versions?
- Determining WordPress’ Version from the Host’s Command Line?
- Is it necessary to bump a plug-in’s version if you’re just updating the “Tested up to” attribute?
- What is the importance of writing a < WP 3.x compatible plugin nowadays?
- Does the event ‘wp_version_check’ even exist? What is it doing?
- Beta Versioning of Plugins
- WordPress install enters an infinite loop
- Release Model for WordPress?
- Reverting from a newer version of WordPress to an older version
- Gallery shortcode menu order fix no longer working on WordPress 4.0
- WordPress 2.8 Widget API is suitable for Worpress 3.1.4 plugins development?
- How to make alert for new version on theme options?
- What are WordPress installation percentages by version?
- Where the WordPress Core Translation is “actually” taking place?
- Where to find WordPress API changes for each version released
- Plugin development: How many plugin and WordPress version combinations to support?
- Relative security of different releases of WordPress
- Where is the changelog for 3.5? where is the list of added removed files?
- How to get all plugins and their version numbers from the local files?
- Updating beyond WordPress 4.2.1 yields “allowed memory size exhausted”
- Customise WordPress Update Notice in wp-admin backend area
- How to order images in a post in WordPress 3.3?
- Where can I find the corrent version of my wordpress blog?
- Is it possible to remove the version number from the wp-login.php page?
- In which version of WordPress was the new gallery shortcode implemented?
- WordPress plugin compatibility explaination when wordpress releases its new version (theoretical)
- Replace or Alter the wp_version_check() Function
- Version 3.04 or 3.5?
- Which Versions of WordPress Ship with the Patched TimThumb?
- Why does WordPress 4.1 have an auto-update entry in wp_options?
- Conditional Javascript based on WP Version
- Is it safe to update from 2.6.2 to the newest version?
- Where in the backend can I get information about the current WordPress version I am using?
- Updating WP 3.9.5 without destroying my website
- Upgrading from Old Version to Latest Version
- WordPress 2.7 upgrade protocol
- Browse Happy in 3.2
- How best to handle database version dependence (from $wp_db_version)
- Implement External API into WordPress [closed]
- Else statement not triggering after a failed if statement
- Downgrade from latest nightly build to latest stable version
- WordPress current version is 5.7.5 but I’m being prompted to “upgrade” to 4.9
- WordPress GUI and wp-cli are saying we have the latest version, but we don’t
- Change the version of default style.css in wordpress
- How do I find out from my database what version of WordPress I need?
- Post Query not working after updating to 4.1
- upgrade v. 2.8.5 to latest version of wordpress
- Background Updates Not Happening
- Split a Multisite Into Single WordPress Websites
- Single WordPress Installation with Sub domains
- Enqueue script throws error in console
- Strange behaviour using 3.8.1
- Disable Please visit the Update Network page to update all your sites. Notice from Dashboard
- Cannot Update wp DB – Get 500 Error
- Is there a Function so that the author of the comment can delete his own comment?
- WordPress plugin not automatic update
- How to remove pop up on website (css changes not visible)?
- Problem with Owl Carousel, infinite loop [closed]