Categories
Functions

Remove meta generator tags by WordPress and other plugins

Meta generator tag in WordPress reveals the plugin or WordPress core version which makes WordPress vulnerable. So, here i list snippets to disable meta tag generator by various plugins.

Remove WordPress & Woocommerce meta tag generator

This code will disable meta tag generated by WordPress, Woocommerce and many other standard plugins that hook up with the wp_generator action.

remove_action('wp_head', 'wp_generator');
add_filter( 'the_generator', '__return_null' );

Remove meta generator tag of revslider plugin

// remove revslider meta generator tag
add_filter( 'revslider_meta_generator', '__return_empty_string' );

Remove meta generator tag of wpbakery page builder plugin

// remove wpbakery visual_composer meta generator tag
add_action('wp_head', 'wpboys_remove_vc_metadata', 1);
function wpboys_remove_vc_metadata() {
  if ( class_exists( 'Vc_Manager' ) ) {
	remove_action('wp_head', array(visual_composer(), 'addMetaData'));
  }
}

Remove meta generator tag of sitepress wpml plugin

// remove wpml meta generator tag
if ( !empty ( $GLOBALS['sitepress'] ) ) {
        function wpboys_remove_wpml_generator() {
            remove_action(
                current_filter(),
                array ( $GLOBALS['sitepress'], 'meta_generator_tag' )
            );
        }
        add_action( 'wp_head', 'wpboys_remove_wpml_generator', 0 );
    }

Complete code Snippet to remove meta generator tags from your WordPress Website

// Disable meta generator tags
// author : wpboys
remove_action('wp_head', 'wp_generator');
add_filter( 'the_generator', '__return_null' );
// remove revslider meta generator tag
add_filter( 'revslider_meta_generator', '__return_empty_string' );
// remove wpbakery visual_composer meta generator tag
add_action('wp_head', 'wpboys_remove_vc_metadata', 1);
function wpboys_remove_vc_metadata() {
  if ( class_exists( 'Vc_Manager' ) ) {
	remove_action('wp_head', array(visual_composer(), 'addMetaData'));
  }
}
// remove wpml meta generator tag
if ( !empty ( $GLOBALS['sitepress'] ) ) {
        function wpboys_remove_wpml_generator() {
            remove_action(
                current_filter(),
                array ( $GLOBALS['sitepress'], 'meta_generator_tag' )
            );
        }
        add_action( 'wp_head', 'wpboys_remove_wpml_generator', 0 );
    }

By Murali Kumar

Murali Kumar is a Full Stack Web Developer with over ten years of experience. He works mostly with small and medium-size businesses. He loves helping businesses with their WordPress based websites.

Leave a Reply

Your email address will not be published. Required fields are marked *