When a site running WordPress loads there’s quite a lot of code in the <head> that some would argue is useless information.

The most publicised of these is the WordPress Generator meta tag which lists you are running WordPress and the WordPress version number.

It’s arguable this is a potential WordPress security issue, although it’s a way for potential hackers to find WordPress blogs running out of date versions of WordPress there’s plenty of other ways hackers can find an out of date WP install: the readme.html file for example (try loading https://stallion-theme.co.uk/readme.html ), won’t load because I delete it after each update, try it on your site and you’ll see something like this:

WordPress Readme HTML

So even if you remove the WordPress meta generator tag there’s other ways hackers can determine your site is running WordPress and the version. Anyway, I digress, this article isn’t specifically about WordPress security.

WordPress Meta Generator Tag

In most WordPress themes in the <head> they will output code like this:

<meta name="generator" content="WordPress 3.9.1" />

This code is generated when a theme includes the WordPress hook wp_head() within the <head> section of a template file (usually the header.php template file).

You can view what’s in the head of your site by going to your WordPress blogs home page in FireFox or Google Chrome and View Source.

The problem with this is broadcasting the version number of WordPress is a potential security issue, especially if you tend not to update WordPress on a regular basis. Basically as a version of a particular software program (like WordPress ages) hackers are more likely to discover serious security flaws in the code of older versions (no software is 100% secure).

When a version of WordPress is found to have a security issue hackers will scan the Internet for websites running that version of WordPress and if your site broadcasts the WordPress version number and you haven’t updated WordPress quickly enough, you may find your site is hacked and ruined!!!

When I first discovered this (2008ish) I tried removing wp_head() from a theme, but the wp_head() hook is important for other reasons, so you can’t just remove it, you have to selectively tell WordPress NOT to load that particular function when WordPress loads and that’s easily achieved at template level by adding this to your templates function.php file (could also add it to a plugin).

<?php remove_action('wp_head', 'wp_generator');?>

Try adding this to the very bottom of your functions.php file, if it doesn’t work try at the very top.

Cleaning the Head Code of WordPress

The wp_head hooks loads a bunch of functions, some of which can safely be removed on many WordPress sites.

Examples include: Really Simple Discovery (RSD) link, Windows Live Writer link and Post relational links.

remove_action wp_head Really Simple Discovery Links

This is the sort of code that’s displayed in the head:

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

This is the link used by XML-RPC clients, basically it’s used for integrating a WordPress site with other services like the Flickr API. If the site isn’t integrated with any other services, you can safely disable this code.

<?php remove_action('wp_head', 'rsd_link');?>

remove_action wp_head Windows Live Writer

This is the sort of code that’s displayed in the head:

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

If you don’t use Windows Live Writer to edit your WordPress site you should be able to safely disable this.

<?php remove_action('wp_head', 'wlwmanifest_link');?>

remove_action wp_head ShortLink

This is the sort of code that’s displayed in the head:

<link rel='shortlink' href='http://www.domain.com/?p=1' />

This is a link to the non permalinks version of a post. Can’t think of a reason why we’d want a link like that in the head?

Remove with:

<?php remove_action('wp_head', 'wp_shortlink_wp_head');?>

remove_action wp_head Index Relational Link

This is the sort of code that’s displayed in the head:

<link rel='index' title='Home Page' href='http://www.domain.com' />

It’s a link to your home page of the WordPress installation. Browsers like FireFox will preload these pages.

Remove with:

<?php remove_action('wp_head', 'index_rel_link');?>

remove_action wp_head Start Relational Link

This is the sort of code that’s displayed in the head:

<link rel='start' title='Your first Post' href='http://www.domain.com/first-post/' />

It’s a link to your first post. Browsers like FireFox will preload these pages. Seriously WordPress developers, what’s the likelihood the very first post someone made is going to be loaded by a visitor next, there’s probably not even a link to that page on most pages of a reasonable size blog?

Remove with:

<?php remove_action('wp_head', 'start_post_rel_link');?>

remove_action wp_head Previous and Next Relational Link

This is the sort of code that’s displayed in the head:

<link rel='prev' title='Previous Post' href='http://www.domain.com/previous-post/' />
<link rel='next' title='Next Post' href='http://www.domain.com/next-post/' />

It’s a link to your previous and next posts. Browsers like FireFox will preload these pages. Unless you have the previous and next links added to your theme it seems to be a waste of time loading these pages in advance. I could understand this concept with paged archive pages like Categories, but not on WordPress posts or pages.

Remove with:

<?php remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');?>

Stallion Theme Usage

All the above WP remove actions are available within the Stallion WordPress SEO theme and Stallion Responsive theme.

WordPress Remove Action

The screenshot above shows the WP remove_actions options under the Stallion Responsive Performance Options page (“Stallion Theme” >> “Performance Options”).

David Law

David Law > AKA SEO Dave
*
: 20+ Years Experience as a Freelance SEO Consultant, WordPress SEO Expert, Internet Marketer, Developer of Multiple WordPress SEO Plugins/SEO Themes Including the Stallion Responsive Theme.

Website - SEO Gold