Clean Up Your WordPress Head Tag

If you look at the source code for your WordPress site you may have noticed a bunch of code in your <head> tag that is not a part of your WordPress theme such as re=”alternative”, rel=”pingpack” and the current version number of your WordPress installation.

These are actions that are added by WordPress and displayed in your wp_head hook – so stop browsing all your theme files trying to figure out how to remove them because you won’t find it there. You’ll need to create some remove_action functions to clean up your WordPress head tag…I’ll show you how to do this.

WordPress <head> Junk?

Below are some examples of what is added to your header. In my opinion a lot of these are unnecessary and I actually remove them all from my site’s header, which is why I call them “junk”. But it really depends on your site and your needs so read up on the rel tags before you go removing them all.

<link rel="alternate" type="application/rss+xml" title="WPExplorer RSS Feed" href="" />
<link rel="alternate" type="application/atom+xml" title="WPExplorer Atom Feed" href="" />
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="" />
<link rel="pingback" href="" />
<link rel='index' title='WP Engineer' href='' />
<link rel='start' title='WPExplorer' href='' />
<link rel='prev' title='WPExplorer' href='' />

How To Remove The WP_Head Actions

In wordpress you can use the function “remove_action” to remove any function that is attached to a specific action hook.

The function remove_action:

remove_action( $tag, $function_to_add, $priority, $accepted_args );


Here you can see how I’ve used the remove_action function to clean up my header. Simply paste the code into your functions.php file to test it out. It should be pretty intuitive to see which action removes what.

// Remove junk from head
remove_action( 'wp_head', 'rsd_link' );
remove_action( 'wp_head', 'wp_generator' );
remove_action( 'wp_head', 'feed_links', 2 );
remove_action( 'wp_head', 'index_rel_link' );
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 );
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );
remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 );
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
AJ Clarke
Post Author: AJ Clarke

Hey. My name is AJ and I am the boss around here. I own and operate WPExplorer. A website dedicated to everything I love about WordPress.

Disclosure: This page contains external affiliate links that may result in us receiving a comission if you choose to purchase said product. The opinions on this page are our own. We do not receive payment for positive reviews.
Got something to say? Join the discussion.
  1. Rajesh Iyer says:
    Hi AJ, Can you help me understand how to remove the Next links and the previous links which comes on every post. I read on some of the sites including this that we have to insert this code on functions.php file: remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); I am not a techie and only handle wordpress a little bit from its dashboard. I would really appreciate if you could tell me where exactly to put this line of code. I mean after which line and before which line on functions.php file? Thanks. Rajesh Iyer
    • AJ Clarke says:
      AJ Clarke
      Hi Rajesh, This depends on your theme, for example on some of my premium themes (like Total) there is an option built-in to the theme panel to disable it. On other themes there might be a filter you can hook into or a function to override. And as a last resort you can removing it by hiding it with CSS. But it all depends on the theme you are using. If you are using a premium theme just message the author and they should be able to help you out!
  2. sama web solutions says:
    thank you AJ Clarke .. helpful post
  3. omnisite2 says:
    You can also use a plugin to remove it and many more stuff from the header. There are some, but I use this one:
    • AJ Clarke says:
      AJ Clarke
      Definitely a plugin may be a good idea if you are using a 3rd party theme. If you are creating your own custom theme for your personal site then having the code in your theme is better because you never know what a 3rd party developer may do in an update.

Leave a Reply