DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

WordPress adds a lot of stuff through wp_head() hook included in most WordPress themes. Some of this stuff is useful, but some other isn’t. Here’s a quick recipe to clean up the wp_head() easily without using a plugin.

Paste the following lines of code into your functions.php file:

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' );

Thanks to Noumaan Yaqoob for the code!

Tags

9 Comments

  1. Nice post but can you tell us please what each line removes?
    What are the risks of doing this and what functionality does this affect?

    • Hello Sean,

      here are my previous snippets with descriptions:

      // Display the links to the extra feeds such as category feeds
      remove_action( ‘wp_head’, ‘feed_links_extra’, 3 );

      // Display the links to the general feeds: Post and Comment Feed
      remove_action( ‘wp_head’, ‘feed_links’, 2 );

      // Display the link to the Really Simple Discovery service endpoint, EditURI link
      remove_action( ‘wp_head’, ‘rsd_link’ );

      // Display the link to the Windows Live Writer manifest file.
      remove_action( ‘wp_head’, ‘wlwmanifest_link’ );

      // index link
      remove_action( ‘wp_head’, ‘index_rel_link’ );

      // prev link
      remove_action( ‘wp_head’, ‘parent_post_rel_link’, 10, 0 );

      // start link
      remove_action( ‘wp_head’, ‘start_post_rel_link’, 10, 0 );

      // Display relational links for the posts adjacent to the current post.
      remove_action( ‘wp_head’, ‘adjacent_posts_rel_link’, 10, 0 );

      // Display the XHTML generator that is generated on the wp_head hook, WP ver
      remove_action( ‘wp_head’, ‘wp_generator’ );

  2. Thank you for this useful code , this will be really helpful.!!!

  3. Good question Sean..

  4. rsd_link – helps blogging client like ecto, WLW to interact nicely with your blog
    wlwmanifest_link – outputs wlwmanifest.xml which is the resource file needed to enable tagging support for Windows Live Writer.
    wp_generator – outputs your WordPress version in XML or Comment for RSS, ATOM

    I would like to know about the others…

  5. Hi,

    Hopefully this covers most of them

    wp_head – Display the link to the Really Simple Discovery service endpoint (ie for pingbacks).

    wlwmanifest_link – Displays the link to the Windows Live Writer manifest file (MS blog tool)

    wp_generator – The generator of the site (WordPress and version number)

    start_post_rel_link – Relational link to first post

    index_rel_link – Relational link to the site index

    adjacent_posts_rel_link – Relational links around current post

    wp_shortlink_wp_head – The URL set as a shortlink (eg /?p=1234) and appears if pretty permalinks are enabled

  6. Great to know. I think Yoast SEO does most of this. I know, it’s a plugin but it’s almost ubiquitous as this point. This is one of the reasons I use it.

  7. hello,
    do you know how to remove WPML infos in the header?

  8. Thanks for handy snippet. But i’m not getting what is the benefit of clean up wp_head. Should i take backup of my current database before doing that?

Leave a Comment

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