Subscribe to the RSS Feed
FreeWordpressThemes.us
Free WordPress Tutorials and Themes.

Remove Unnecessary Code from wp_head

November 4th, 2013 by admin

WordPress adds a lot of stuff through wp_head() hook included in most WordPress themes. Most of this stuff I would consider unnecessary. But for many users, a few lines of extra code is probably not much of a bother. It doesn’t slow down their site or harm their search rankings. As for me, I like to keep things simple, clean, and if I don’t need some code on every page of my site, then it must be removed.

In this quick tip post, I will show you how to remove the following unnecessary code from your site’s wp_head section:

  • Really Simple Discovery (RSD) link
  • Windows Live Writer link
  • Shortlink for posts

The simplest most efficient way I have found to clean up the wp_head section, is by using WordPress SEO plugin by Yoast (Checkout our video review of WordPress SEO). Many people think of WordPress SEO plugin as just an SEO plugin. I look at it as a website optimizer plugin. It comes with lots of goodies that optimize the over all performance of a WordPress site, and cleaning up the wp_head section is one such feature.

Simply install and activate Yoast’s WordPress SEO plugin. Upon activation, it adds a WordPress SEO menu item in your WordPress admin sidebar. You need to go to WordPress SEO ยป Titles & Metas and scroll down to Clean up the <head> section.

There you can simply uncheck the items you want to remove from wp_head section of your WordPress site.

Cleaning up wp_head() Without a Plugin

To remove all unnecessary code from wp_head() section without using a plugin you need to remove all these items from wp_head() hook. Simply add this code in your theme’s functions.php file:

<?php
remove_action( 'wp_head', 'rsd_link' );
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'wp_generator' );
remove_action( 'wp_head', 'start_post_rel_link' );
remove_action( 'wp_head', 'index_rel_link' );
remove_action( 'wp_head', 'adjacent_posts_rel_link' );
remove_action( 'wp_head', 'wp_shortlink_wp_head' );
?>

Unlike WordPress SEO plugin, the above code also removes post relational links, shortlink, and WordPress generator information from your site’s head section.

As I said earlier that these few lines don’t do any harm to your website’s page load speed or search rankings. However, if you just want to remove useless code then you should start with this.

The post Remove Unnecessary Code from wp_head appeared first on Theme Lab.

Written by - Visit Website

Posted in Theme Labs

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.