WordPress - How to remove meta generators?

I have these tags:

<meta name="generator" content="Woo Framework Version 3.1.1" /> <meta name="generator" content="WordPress 3.5" /> <meta name="generator" content="Canvas 3.0" /> 

I understand to remove the tag of the WordPress version that I am adding:

 remove_action( 'wp_head', 'wp_generator' ); // goes into functions.php 

But how do I remove meta themes?

+11
source share
8 answers

If you are trying to remove only meta="generator" add this line to the functions.php file.

 remove_action( 'wp_head', 'wp_generator' ); 
+16
source

I was looking for a solution to remove the Layer Slider meta generator, I did not find much help on any of the few sites I looked at, they all share the same information that applies only to WordPress generator or popular plugins like WooCommerce .

The problem is that each plugin will have its own hook names and naming conventions, so it will be almost impossible to find or recognize them all. I think the easiest way is simple PHP with preg_replace .

Working code tested in WordPress 4.7.2 . Paste this code inside the functions.php of your theme and it should work.

 //Remove All Meta Generators ini_set('output_buffering', 'on'); // turns on output_buffering function remove_meta_generators($html) { $pattern = '/<meta name(.*)=(.*)"generator"(.*)>/i'; $html = preg_replace($pattern, '', $html); return $html; } function clean_meta_generators($html) { ob_start('remove_meta_generators'); } add_action('get_header', 'clean_meta_generators', 100); add_action('wp_footer', function(){ ob_end_flush(); }, 100); 

I use regex to capture meta . It covers whether they put spaces between the equal sign or not. Using ob_start to cover the entire document. Therefore, we add preg_replace from the header to the preg_replace header. See how ob_start works in the PHP manual, sometimes WordPress code states that it should use ob_start .

If you find this helpful, please add a thumbs up so that the next seeker can find a working solution covering all the meta-generators. I consider it poor security for plugin and platform developers to embed version numbers of meta generators in code. Especially with constantly emerging vulnerabilities.

I also added a plugin that does exactly that in the WordPress repository .

Remove meta generators

+14
source

I found this plugin source code which says that it removes the automatically generated WP meta tags. You can try this.

  • Plugin Name: Remove WP Meta li>
  • Plugin URI: http://leekelleher.com/
  • Description: This plugin removes automatically generated WP meta tags from each web page.
  • Posted by: Lee Kelleher
+3
source

At the bottom of the functions.php file, add the following php snippet:

 // hide the meta tag generator from head and rss function disable_version() { return ''; } add_filter('the_generator','disable_version'); remove_action('wp_head', 'wp_generator'); 
+2
source

I recently ran into this problem and had to remove the meta tags for security and spam for the client. I managed to remove the Wordpress meta generator, but the theme uses woo framework, so

 remove_action('wp_head', 'wp_generator'); 

Not enough. To delete

 <meta name="generator" content="Woo Framework Version xxx" /> 

and any meta generator tags that your theme generates, just add this line at the end of your functions.php template

 // remove the unwanted <meta> links remove_action('wp_head', 'wp_generator'); remove_action('wp_head', 'woo_version'); 

This worked for me on Woo Framework 5.5.5. To determine the place where the generator meta tag is initialized, find the admin-init.php for your template, and the woo_version() function and the woo_version_init() function should be there. It is usually located under the include folder in your theme source.

+2
source

NOT!

In case it is hardcoded into the theme template (i.e. in header.php), you must manually delete this!

Otherwise, use this complete solution to remove all version tags:

 // ============ removing inbuilt WP version meta-tags =========== http://stackoverflow.com/q/16335347/2377343 ========== // //if included in wp_head add_action( 'after_setup_theme', 'my_wp_version_remover' ); function my_wp_version_remover(){ remove_action('wp_head', 'wp_generator'); //remove inbuilt version remove_action('wp_head', 'woo_version'); //remove Woo-version (in case someone uses that) } //clean all responses from VERSION GENERATOR add_filter('the_generator', 'rm_generator_filter'); add_filter('get_the_generator_html', 'rm_generator_filter'); add_filter('get_the_generator_xhtml', 'rm_generator_filter'); add_filter('get_the_generator_atom', 'rm_generator_filter'); add_filter('get_the_generator_rss2', 'rm_generator_filter'); add_filter('get_the_generator_comment', 'rm_generator_filter'); add_filter('get_the_generator_export', 'rm_generator_filter'); add_filter('wf_disable_generator_tags', 'rm_generator_filter'); function rm_generator_filter() {return '';} // Hide "?vers=XXXXX" strings from scripts and styles ( https://premium.wpmudev.org/blog/how-to-hide-your-wordpress-version-number/ ) add_filter( 'script_loader_src', 'fjarrett_remove_wp_version_strings' ); add_filter( 'style_loader_src', 'fjarrett_remove_wp_version_strings' ); function fjarrett_remove_wp_version_strings( $src ) { global $wp_version; parse_str(parse_url($src, PHP_URL_QUERY), $query); if ( !empty($query['ver']) && ($query['ver'] === $wp_version || $query['ver'] == $wp_version) ) { $src = remove_query_arg('ver', $src); } return $src; } // ========================================================== // 
+2
source

The following code eliminates all generator tags in the Woo Framework. I tested it using Woo Framework 6.0.4 and the Canvas 5.8.3 theme:

 // Remove the WooThemes version from the html headers function no_woo_version () { return true; } add_filter ('wf_disable_generator_tags', 'no_woo_version'); 
+1
source

If you created your own WordPress theme, you will not have problems with the generator in the meta code, do as I did in the samll sample. There will be no generator unless you declare it as some of your custom functions. I try to control all the JS scripts and styles of my theme, like here . If I have a style from plugins, a little more work is needed there.

but if you use a free theme, yes in 100% there will be a generator. Therefore, add Function.php 1 to the file: http://sierra-group.in.ua/start-legkogo-rezhima-preprocesornoj-sborki-vashih-fajlov-stilej-i-skriptov.html/#custom-register-styles- sctiprs

 function disable_version() { return '';} add_filter('the_generator','disable_version'); remove_action( 'wp_head', 'wp_generator'); remove_action('wp_head', 'woo_version'); function no_woo_version (){ return true;} add_filter ('wf_disable_generator_tags', 'no_woo_version'); 
0
source

All Articles