How to Remove WooCommerce Generator Tag

WooCommerce Generator Tag

WooCommerce Generator TagSometime we needed our Code to be clean without any extra meta tags generated by different WordPress Plugins we have installed on our site. Like many other plugins, WooCommerce also added it’s Generator Tag into Source Code of your website.

If you are not debugging your website than it’s good to remove this tag for above reason and one other more important reason i.e. Security purpose. Some time we finished website for a client and later you are not managing the website updates and it’s on client end.. most probably they won’t do any updates on there website leaving security hole into there website by letting people know which version they are using for particular plugin.
Like WordPress, Plugin author keep there plugins updated maintaining themself updated with new code of WordPress but if you have old version on your website there are chances someone attack your website by manipulating old plugins security holes.

Good thing about WooCommerce is that it allows different hooks and functions to over ride it’s default outputs of code, which make things lot easier if you understand what you wanted to achieve.

here is the code snippet to remove WooCommerce Generator Tag from the source code of your WordPress Website, you can add this into functions.php file:

Remove WooCommerce Generator Tag from version 2.1 and latest

function my_woocommerce_loaded_function() {
 global $woocommerce;
 remove_action( 'wp_head', array( $woocommerce, 'generator' ) );
}

add_action( 'woocommerce_init', 'my_woocommerce_loaded_function' );

Remove WooCommerce Generator Tag from previous versions

function my_woocommerce_loaded_function() {
 global $woocommerce;
 remove_action('wp_head', array($GLOBALS['woocommerce'],'generator'));
}

add_action( 'woocommerce_init', 'my_woocommerce_loaded_function' );

Leave a Reply