How to Remove WordPress Version Number

In this tutorial i will teach you how you can hide wordpress version manually. We won't use plugin to do this simple task. I will do it with our own code. We can hide or remove wordpress version number with many ways. Sometimes many client wants to remove version number from wordpress css and js files. 

To do this simple wordpress remove version number from css and js files, let's see how we can do it. We will use filter to remove wordpress version number from css and js files.

 

Method  One

Removes WordPress version number from WP_Head

< ? php

   function remove_or_hide_wordpress_version_number() {

        return '';

   }

   add_filter('the_generator', 'remove_or_hide_wordpress_version_number');

? >

 

Method  Two 

Removes WordPress version number 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 Three

Removes all wordpress version numbers from all enqueued or included CSS and JS files – the most thorough, which will remove “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 );