How to Remove WordPress Version Number?

Nov 03, 2022

.

Admin

How to Remove WordPress Version Number?

Hi Dev,

In this post, we will learn how to remove the WordPress version numbers. you can understand the concept of how to hide the WordPress version manually. We will look at examples of removing WordPress version numbers. I would like to share with you the removed version number of WordPress. So, let's follow a few steps to create an example of removing version numbers in WordPress.

There are examples of Remove Version Number in WordPress. so Let's the following example with output.

Method 1:


WP_Head

<?php

function remove_or_hide_wordpress_version_number() {

return '';

}

add_filter('the_generator', 'remove_or_hide_wordpress_version_number');

?>

Method 2:

Removes version number of WordPress from all enqueued or included CSS and JS files

// remove wp version param from any enqueued scripts

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 );

Method 3:

Removes all WordPress version numbers from all enqueued or included CSS and JS files – the most thorough, which will remove the “ver” parameter from every included or enqueued js and CSS file.

// remove wp version param from any enqueued scripts

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 );

I hope it could help you...

#Wordpress