Remove Unnecessary Codes From The Head Section of Your WordPress Theme

The following tips are applicable for both self hosted WordPress blogs and blogs that are hosted on WordPress.com’s free blogging platform.

If you have a blog or a website powered by WordPress content management system, you might have noticed some lines of code before the </ head> section of your website’s WordPress theme. While some of the codes are useful and have a purpose, a few of them are not.

This tutorial shows you how to remove unnecessary codes from the head section of a WordPress theme.

Remove unnecessary codes from WordPress headerLet’s take a look at some example codes ne by one

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

WordPress supports an XML-RPC interface which is used by blogging clients like Windows Live writer, Ecto etc for publishing blog posts to your website directly from desktop. If you always use a browser to write blog posts within your WordPress administration area, the above line of code is not useful.

2. <link rel=”wlwmanifest” type=”application/wlwmanifest+xml” href=http://example.com/wp-includes/wlwmanifest.xml />

The wlwmanifest.xml file is used by Windows Live writer to fetch Tags and Categories of your WordPress blog on the desktop blogging client. Again, if you are not using Windows Live writer to write blog articles, this code is meaningless.

3. <link rel=’index’ title=” href=’http://example.com/’ />

The recent version of WordPress 3.0 automatically inserts a link rel tag on the head section of your WordPress theme which points to your homepage. This is not to be confused as an SEO improvement.

Instead, some WordPress themes might use this tag for varied reasons. If your theme does not refers to this tag or makes a call, you should better remove the index page referrer from the head section of your WordPress theme.

4. <link rel=’start’ title=” href=’http://example.com/first-post/’ />

This is another annoying piece of code which points to the first post published on your current WordPress installation. The annoying part is that WordPress automatically embeds this code on the head section of every page on your site. Again, this code does not help in SEO or better crawling of your pages.

5. <link rel=’prev’ title=” href=’http://example.com/previous-post/’ />

<link rel=’next’ title=” href=’http://example.com/next-post/’ />

Above pair of codes are another rel link which points to the previous and next blog entry. Serves no real purpose.

6. <meta name=”generator” content=”WordPress 3.1.2″ />

This one is added from the WordPress header hook and shows the  WordPress version installed on your site. It can be a security concern, so you should remove it as well.

7. <link rel=’shortlink’ href=’http://wp.me/abcde’ />

This is the shortlink version of a published post on your blog, which is embedded from the WordPress header hook. Some themes are coded to use it, so before dropping this one, please double check and verify that you are not using this value anywhere on your theme.

Removing these unnecessary codes from the head section of your WordPress theme is fairly easy. Open your theme’s functons.php file and paste the following codes (be careful, take backups first).

remove_action( ‘wp_head’, ‘wp_shortlink_wp_head’, 10, 0 );
remove_action(‘wp_head’, ‘rsd_link’);
remove_action(‘wp_head’, ‘wlwmanifest_link’);add_filter( ‘index_rel_link’, ‘remove_code’ );
add_filter( ‘parent_post_rel_link’, ‘remove_code’ );
add_filter( ‘start_post_rel_link’, ‘remove_code’ );
add_filter( ‘previous_post_rel_link’, ‘remove_code’ );
add_filter( ‘next_post_rel_link’, ‘remove_code’ );
add_filter(‘post_comments_feed_link’,’remove_code’); 

function remove_code( $data ) {
return false;
}

While keeping the above codes in the head section of your theme won’t harm your site in any sense, but it’s always better to reduce overhead of HTML markup and serve only what is required. Why increase the overall size of all the pages of your site with useless machine generated stuff which serves no purpose at all?

Important note: It’s important to note that all of the above codes can be removed by editing core WordPress files (e.g wp-includes/wlmanifest.xml). But I would suggest you to use theme specific codes for two reasons. First, when you upgrade WordPress to it’s latest version, all your customized hooks will be overwritten with their default code which will bring the earlier codes back.

Second, isn’t it always easy to enable or disable stuff from a theme or a plugin when compared to editing core WordPress files, which can break existing features?

Related articles

Dell Inspiron i7559-3763BLK

Best Laptops Under $1500 for Everyday Usage

Bulk UnFollow Inactive Twitter Followers

How to See Follower Stats and Bulk UnFollow Inactive Twitter Followers

How to Control Google Play Music When Screen is Locked on Android

How To Control The Music App On Your Android When The Screen Is Locked

Browser Opening An Unknown Page At System Startup

Is Your Browser Opening An Unknown Page At System Startup? Here is The Fix

1 comment

  1. Elfreda Rupprecht says:

    It reminds me of Caddyshack.

    https://

Leave a Reply

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