Skip to content

Instantly share code, notes, and snippets.

@mrkdevelopment
Created May 2, 2026 02:04
Show Gist options
  • Select an option

  • Save mrkdevelopment/8dbb21a2e54cb1d553e4cf1b5b03f95b to your computer and use it in GitHub Desktop.

Select an option

Save mrkdevelopment/8dbb21a2e54cb1d553e4cf1b5b03f95b to your computer and use it in GitHub Desktop.
A snippet of code to hide the version numbers of WordPress and all plugins and themes in your setup.
// 1. Remove the version number from the site's <head> (Meta Generator)
remove_action( 'wp_head', 'wp_generator' );
// 2. Remove the version number from RSS feeds
add_filter( 'the_generator', '__return_empty_string' );
/**
* Replace all script and style version numbers with a Year-Month string
*/
function replace_version_with_month( $src ) {
// Check if the URL contains a 'ver=' parameter
if ( strpos( $src, 'ver=' ) ) {
// Generate the current year and month (e.g., "202604" for April 2026)
$monthly_ver = date( 'Ym' );
// Strip the original plugin/theme version
$src = remove_query_arg( 'ver', $src );
// Append our custom monthly version
$src = add_query_arg( 'ver', $monthly_ver, $src );
}
return $src;
}
// Use a higher priority (15) to ensure this runs after plugins try to add their versions
add_filter( 'script_loader_src', 'replace_version_with_month', 15, 1 );
add_filter( 'style_loader_src', 'replace_version_with_month', 15, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment