Hello Dev,
Today, i we will show you how to remove version number in wordPress. This article will give you simple example of how to remove version number in wordPress. you will learn how to remove version number in wordPress. We will be filter to remove wordpress version number from css and js files.
I will give you 3 examples. So let’s follow few step to create example of how to remove version number in wordPress.
Example 1
Removes version number from WP_Head
< ? php function remove_or_hide_wordpress_version_number() { return ''; } add_filter('the_generator', 'remove_or_hide_wordpress_version_number'); ? >
Example 2
Remove version number from all enqueued or include CSS and JS files
function remove_or_hide_wordpress_version_number( $src ) { if ( strpos( $src, 'ver=' ) ) $src = remove_query_arg( 'ver', $src ); return $src; } add_filter( 'style_loader_src', 'remove_or_hide_wordpress_version_number', 9999 ); add_filter( 'script_loader_src', 'remove_or_hide_wordpress_version_number', 9999 );
Example 3
the most example, which will remove version number parameter from every included or enqueue js and css file.
function remove_or_hide_wordpress_version_number( $src ) { if ( strpos( $src, 'ver=' . get_bloginfo( 'version' ) ) ) $src = remove_query_arg( 'ver', $src ); return $src; } add_filter( 'style_loader_src', 'remove_or_hide_wordpress_version_number', 9999 ); add_filter( 'script_loader_src', 'remove_or_hide_wordpress_version_number', 9999 );