nav-left cat-right
cat-right

Removing wp_head() elements (rel=’start’, etc.)

Removing wp_head() elements (rel=’start’, etc.)

In customising WordPress you may find a need to occasionally remove or add to the Link elements that WordPress automatically outputs in the function call wp_head(). I’ve recently had a need to remove the rel=’prev’ and rel=’next’ link elements and in trying to avoid customising the core WordPress functions the following solutions works.

Ensure you have a functions.php file in your theme directory that you are using. If not create the file and edit the file. The following lines will help remove select lines from your wp_head() function:

remove_action( 'wp_head', 'feed_links_extra', 3 ); // Removes the links to the extra feeds such as category feeds
remove_action( 'wp_head', 'feed_links', 2 ); // Removes links to the general feeds: Post and Comment Feed
remove_action( 'wp_head', 'rsd_link'); // Removes the link to the Really Simple Discovery service endpoint, EditURI link
remove_action( 'wp_head', 'wlwmanifest_link'); // Removes the link to the Windows Live Writer manifest file.
remove_action( 'wp_head', 'index_rel_link'); // Removes the index link
remove_action( 'wp_head', 'parent_post_rel_link'); // Removes the prev link
remove_action( 'wp_head', 'start_post_rel_link'); // Removes the start link
remove_action( 'wp_head', 'adjacent_posts_rel_link'); // Removes the relational links for the posts adjacent to the current post.
remove_action( 'wp_head', 'wp_generator'); // Removes the WordPress version i.e. - WordPress 2.8.4

Don’t remove these items unless you have a need to. The WordPress generator removal could be useful if you are not religiously upgrading your WordPress install as it helps hide the WP version from potential hackers to a certain degree.

23 Responses to “Removing wp_head() elements (rel=’start’, etc.)”

  1. Jason says:

    Great info. Not sure when you would need all of these, but I needed to remove the WordPress version and this worked great.

    Thanks 🙂

  2. Shoffy says:

    I wish I had something more significant to add… but thanks. Great info.

  3. Grab Voucher Codes says:

    Thanks for sharing! Just what I was looking for.

  4. yarongold says:

    Was looking for this! Any solution on how to remove the canonical tag?

  5. Allie says:

    Excellent quick reference. Thanks so much!

  6. Mike says:

    When I did this, I got an error when I tried to edit a post.

  7. mike says:

    remove_action( ‘wp_head’, ‘feed_links’, 2 );

    That one does nothing for me…

  8. Andy says:

    does not work

    added to my theme functions.php

    i am using atahualpa theme

    wonder why?

    please help

  9. Santosh Bhandarkar says:

    Excellent, i was wondering how to remove the sections from the header – thanks.

  10. ROB says:

    I still have the rel=”prev” & rel=”start” listed in my header how do I remove it?

    Is there any other place where it could be hidden…

  11. Quizzer says:

    exelent info very very thanks =)

  12. Sergio says:

    Prev and Next still remains in WP 3.0

  13. Spelautomater says:

    Removing most of this should be usefull right? Less code on site will help to speed it up. I dont see any of the above really useful so i just removed it all. Thanks a lot.

  14. IT??? says:

    Thanks. What I wanna say is we may use

    wp_deregister_script(“jquery”);
    wp_head();

    at the header.php to drop the jquery (70kb) and light your wordpress

  15. Thanks a lot. Exactly what I was looking for!

  16. The 3.0 version needs “adjacent_posts_rel_link_wp_head”

    I don’t know why the “wp_head” was added.

  17. Pofesor Yeow says:

    Thanks! you save my life!

    eeh.. one question.. if good to make “start” with frontpage of the site? (same like the index)
    and if it’s good.. how to make?

    any ways, you save my life, now i can remove the F##K start rel to my old post

    THANKS!

  18. Easier way is to write the following lines in your themes functions.php file

    add_filter( 'index_rel_link', 'disable_stuff' );
    add_filter( 'parent_post_rel_link', 'disable_stuff' );
    add_filter( 'start_post_rel_link', 'disable_stuff' );
    add_filter( 'previous_post_rel_link', 'disable_stuff' );
    add_filter( 'next_post_rel_link', 'disable_stuff' );

    function disable_stuff( $data ) {
    return false;
    }

  19. Biju Subhash says:

    thank you…
    its help me to save time…

  20. Not working for me to remove the link.

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

    Any idea for wordpress 3.3.1

  21. friv says:

    hi, admin disable rel=”tag” links?

Trackbacks/Pingbacks

  1. travistubbs.net - Travis Allen Tubbs - [...] on your theme, there may be more functions added to the head of your site. Check out http://rjpargeter.com/2009/09/removing-wordpress-wp_head-elements/ for…
  2. Removing wp_head() elements (rel=’start’, etc.) - dhansson - dhansson - [...] Removing wp_head() elements (rel=’start’, etc.) Relaterade inlägg :Periodic Table of the Elements - Josh DuckLinux Start Restart and Stop…
  3. wp_head(); içindeki rel=’start’ gibi taglar? temizlemek » Samet MĂĽtevellio?lu - [...] Siz de bunlardan kurtulmak istiyorsan?z, gelin kald?ral?m ?u taglar?! Bu yaz?y? haz?rlarken ?u adresten ilham ald???m? belirtmek istiyorum, zira…
  4. ??wp_head()??WordPress??_??? - [...] Removing wp_head() elements (rel=’start’, etc.) [...]
  5. next and prev tags in Wordpress Themes | | Industry Marketing GuideIndustry Marketing Guide - [...] To learn how to remove the rel=”prev” and rel=”next” tags from your headers for Wodpress 3 you can visit…
  6. WordPress: Remove RSS (e.g. Page / Comments) Feed from Head - […] Other stuff: Removing wp_head() elements (rel=’start’, etc.) […]

Leave a Reply

Your email address will not be published.