How to remove unnecessary meta tags and data from WordPress pages?

Updated on September 2, 2017

If you were wondering how to remove unnecessary meta tags added to HTML source code of your wordpress site, then here’s how you can do that. By default wordpress adds few meta tags and link tags to HTML source code (such as wordpress version, manifest and rsd), that are not used mostly. Moreover, wordpress meta tag can let others know the version of CMS that you are currently running and you know hackers love such information.

Here’s a sample meta and link tag added by wordpress,

<meta name="generator" content="WordPress 2.3.3" />
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://kannadahanigalu.com/xmlrpc.php?rsd" />
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://kannadahanigalu.com/wp-includes/wlwmanifest.xml" />

To remove meta tag and link tag from the HTML source of your wordpress site, add the below lines to your theme function.php file.

remove_action( 'wp_head', 'wp_generator' ) ;
remove_action( 'wp_head', 'wlwmanifest_link' ) ; 
remove_action( 'wp_head', 'rsd_link' ) ;

Update: If the above code didn’t work for you, then you may try the alternate solution – add the below code to functions.php in your theme directory

function remove_generator_filter() { return ''; }

if (function_exists('add_filter')) {
 $types = array('html', 'xhtml', 'atom', 'rss2', /*'rdf',*/ 'comment', 'export');

 foreach ($types as $type)
 add_filter('get_the_generator_'.$type, 'remove_generator_filter');
}

Checkout this guide as well : WordPress security tips

Was this article helpful?

Related Articles

Comments Leave a Comment

Leave a Comment