How do I edit wp_head and/or functions.php to remove rss-feed which isnt used and dont validate?

When using w3.org’s validation tool Unicorn I get the following error/warning:

URI: http://energyshop.se/hem/feed/
This feed does not validate.

Read More

After looking into my source its there crystal clear in the <head>:
<link rel="alternate" type="application/rss+xml" title="energyshop.se &raquo; Hem kommentarsflöde" href="http://energyshop.se/hem/feed/" />

Now, how do I remove this feed since I dont use it?

Thanks in advance!

Related posts

Leave a Reply

2 comments

  1. If we look at the file

    /wp-includes/default-filters.php
    

    we can find these two lines in there

    add_action( 'wp_head',             'feed_links',                      2     );
    add_action( 'wp_head',             'feed_links_extra',                3     );
    

    so if we want to remove these actions, we can do it with these two lines in functions.php:

    remove_action('wp_head','feed_links',2);
    remove_action('wp_head','feed_links_extra',3);
    

    So the feed links will be removed from the <head> tag.

    ps: In this file you will also find:

    add_action( 'do_feed_rdf',                'do_feed_rdf',                             10, 1 );
    add_action( 'do_feed_rss',                'do_feed_rss',                             10, 1 );
    add_action( 'do_feed_rss2',               'do_feed_rss2',                            10, 1 );
    add_action( 'do_feed_atom',               'do_feed_atom',                            10, 1 );
    

    If you want to disable the feeds, you can remove these hooks in a similar way with:

    remove_action( 'do_feed_rdf', 'do_feed_rdf', 10, 1 );
    remove_action( 'do_feed_rss', 'do_feed_rss', 10, 1 );
    remove_action( 'do_feed_rss2', 'do_feed_rss2', 10, 1 );
    remove_action( 'do_feed_atom', 'do_feed_atom', 10, 1 );
    

    but then you will get this message when you visit the feed links

    enter image description here

    You might consider making url rewrites for the feed links or make a custom feed template, to get rid of this message.

  2. The third params are also required, without them it didn’t work for me

    remove_action('wp_head','feed_links',2);
    remove_action('wp_head','feed_links_extra',3);