Problem/Use Case:
WordPress outputs its version number in the site’s source code, which can expose your site to potential hackers.
Snippet (functions.php):
// Remove WordPress version from head
remove_action('wp_head', 'wp_generator');
Explanation:
This removes the generator meta tag from your site’s <head> section, hiding the WordPress version number.
Where to Place It:
Add this snippet in your theme’s functions.php file or a custom plugin.
Bonus Tip:
You can also hide the version from RSS feeds by adding:
add_filter('the_generator', '__return_empty_string');