How to cleanup WordPress header is one of the common questions people ask when they start optimizing their WordPress sites.

Constantly investing time to speed up your WordPress and keep everything clean will have big benefits to your SEO (Search Engine Optimization). Furthermore, it will make the look and feel of your site better and keep your visitors happy and returning. Here I assume that you are maintaining your WordPress in the right way so far.

Now, approach where we install huge amount of plugins in order to accomplish this is not good. Why? Because you might end up increasing your complexity instead of cleaning up.

Table of Contents

How to cleanup WordPress header?

Smart way to cleanup your header is to write several snippets. In this tutorial, you will find most common header cleanup snippets. Each snippet is followed by explanation on how and why to use it.

Remove WordPress version number

WordPress version number tells everyone which version is your WordPress using. This is easily readable in your web site code or your RSS feed. If you are running latest version of WordPress then this is not a problem. However if you are having older WordPress version (non updated version of WordPress) then this information will point out to security hole which can be used to damage your site.

The solution for this is to keep your WordPress clean and updated. On the other side, there is a way to remove version information from your header. After that, your header will be cleaner and you will give away less security-related information.

WordPress version looks like this.

<meta name="generator" content="WordPress 5.2.3">

Quick and dirty way to remove WordPress version is to remove action which generates this data in header.

remove_action('wp_head', 'wp_generator');

This looks ok, but your WordPress version is still visible on the other places (i.e. your RSS feed.). To remove your WordPress version completely, use this snippet somewhere inside your functions.php file.

function remove_wordpress_version_number() {
	return '';
}
add_filter('the_generator', 'remove_wordpress_version_number');

Windows Live Writer was a desktop blog and publishing application developed by Microsoft. It was distributed as part of the Windows Live suite of applications. Furthermore, the last major release of this software was in 2012. After that, this software was completely discontinued in 2017.

For some reason, link that generates readable xml format of your posts for this software is still available in WordPress.

<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://milanlatinovic.com/wp-includes/wlwmanifest.xml">

If you or your customers do not use Windows Live Writer, then you should disable this link, which will clean up your WordPress header a bit. You can do this easily by using remove_action line in your functions.php file.

remove_action('wp_head', 'wlwmanifest_link');

Really Simple Discovery helps client software to find services needed to read, edit, or communicate with web blog software. For example, link looks like this.

<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://milanlatinovic.com/xmlrpc.php?rsd">

You can quickly remove this by using this action.

remove_action('wp_head', 'rsd_link');

What else can you do?

As I mentioned in previous posts, to clean up your WordPress and keep it fast, you can setup a proper CSS and JS minification as explained here.

Firstly, you can also make your WordPress archive and search results more readable by limiting the number of posts on an archive page.

Secondly, you can also remove unwanted pages from your search mechanism with this simple snippet.

Hopefully, this makes sense and you find these snippets useful.

In addition, if this post was helpful for you, please share and comment below!