Software Developer

Remove Unwanted Links and Tags From WordPress Head

Update: 3 widely unpopular “rel” link tags have been deprecated so you don’t have to remove them anymore. See Deprecated rel_link Tags in WP Head.

This removes those extra ‘rel’ links that WordPress inserts into wp_head. It also removes the WP generator tag. Removing some of these are useful for keeping your site more secure (for example, the Edit Uri link). Removing all of these makes your pages load faster.

There is nothing you will miss here. I don’t touch the ‘canonical’ link, nor the “shortlink”, because those are useful for traffic to your site. The “canonical” lets Google know your page is the original source, and the “shortlink” allows your page to be shared far and wide in feeds like Twitter. So, drop the whole chunk below into your functions to get rid of useless clutter.

remove_action( 'wp_head', 'rsd_link' );

// remove the link rel="wlwmanifest"
remove_action( 'wp_head', 'wlwmanifest_link' ); 

// remove the meta generator WP version tag
remove_action( 'wp_head', 'wp_generator' );

// remove both link rel="prev" and link rel="next"
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );

// remove the link rel="alternate" feed links for regular posts fee and comments feed
remove_action( 'wp_head', 'feed_links', 2 ); 

// Remove links to the extra feeds (e.g. category feeds)
remove_action( 'wp_head', 'feed_links_extra', 3 );


We've 2 Responses

  1. November 30th, 2015 at 9:15 am

    thanks for this. The rel=”prev” and rel=”next” was preventing the page from loading completely. I’m guessing it’s because the browser, Firefox, was using that as a means of pre-rendering the next page. once i added

    // remove both link rel="prev" and link rel="next"
    remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );

    in the functions.php file for my theme, they were removed and the problem was solved.


Questions and Comments are Welcome

Your email address will not be published. All comments will be moderated.

Please wrap code in "code" bracket tags like this: