WordPress – How do I remove meta generator tags?

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 WordPress version tag I add:

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

But how do I remove the themes meta tags?

Related posts

Leave a Reply

10 comments

  1. Was looking for a solution for removing Layer Slider meta generator, didn’t find much help on any of the handful of websites I looked at, they are all sharing the same info, which only pertains to either WordPress generator or popular plugins like WooCommerce.

    The problem here is that every plugin is going to have it’s own hook names and naming conventions, so to learn or know them all will be nearly impossible. The easiest way I think is plain PHP with preg_replace.

    Working code that has been tested in WordPress 4.7.2.
    Inside functions.php of your theme drop in this code 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 am using regular expression to capture the meta tag. It covers whether they put spaces in between the equals sign or not. Using ob_start to cover the whole document. So we add the preg_replace starting at the header all the way to the footer. See how ob_start works in the PHP Manual, also there are times WordPress codex does states it should be using ob_start.

    If you find this useful please add a thumbs up so the next person looking can land on a working solution that covers all meta generators. I feel it’s bad security for these plugin and platform developers to put meta generator version numbers in the code. Especially with evolving vulnerabilities being discovered all the time.

    Ive also added a plugin that does this exact thing on the WordPress repository.

    Remove Meta Generators

  2. At the bottom of the functions.php file add this 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');
    
  3. I recently ran into this issue, and had to remove the meta tags for security and spam reasons for a client. I was able to remove WordPress’s meta generator but the theme uses woo framework so using

    remove_action('wp_head', 'wp_generator');
    

    Is not sufficient. To remove

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

    and anything any meta generator tags that your theme generates simply add this line to the end of your template’s functions.php

    // 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 locate where the generator meta tag is initialized, look for your admin-init.php file for your template and woo_version() function and woo_version_init() function should be there. Usually its under the includes folder within your theme source.

  4. I found this source code of a plugin which states that it removes the auto-generated WP meta tags. You could try that.

    • Plugin Name: Remove WP Meta
    • Plugin URI: http://leekelleher.com/
    • Description: This plugin removes the auto-generated WP meta tags from each webpage.
    • Author: Lee Kelleher
  5. NO!

    In case if it is hardcoded into your theme’s template (i.e. in header.php),then you have to manually remove that!

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

    // ============ removing inbuilt WP meta-tag ===========  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'); 
        }
      //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 '';}
    // ========================================================== //
    
  6. The following code gets rid of all generator tags in the Woo Framework. I have tested it with Woo Framework 6.0.4 and the theme Canvas 5.8.3:

    // Remove the WooThemes version from the html headers
    function no_woo_version ()
    {
       return true;
    }
    add_filter ('wf_disable_generator_tags', 'no_woo_version');
    
  7. This one finds the sitekit by Google, but can be modified for anything. Thanks to this article and his plugin.

    add_action('get_header',function (){
        ob_start(function ($o) {
            return preg_replace('/n?<.*?content="Site Kit by Google.*?>/mi','',$o);
        });
    });
    add_action('wp_head',function (){
        ob_end_flush();
       }, 992);
    
  8. If you made your ouw custom WordPress theme, there will be no problem with generator in meta, DO like i Did in samll sample. There will be no generator, if you will not declare it like some of your custom functions. I try to control all JS scripts and Styles of my theme like here.
    If i have, style from plugins, there some more Job needed.

    but if you use, free theme, yes in 100% there will be generator.
    So add in File Function.php 1: 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');