11

I am talking about this line of code

<link rel="alternate" type="application/rss+xml" title="example.com &raquo; Comments Feed" href="http://example.com/comments/feed/" />

I have tried adding a remove action hook manually in template's functions.php

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

But it doesn't remove it.

I have tried wordpress head cleaner plugin unfortunately it also couldn't remove it.

At last I have edited wp-includes/default-filters.php and commented out

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

My comment feed links are still there. I prefer functions.php modification or plugins other than modifying the core files.

I have tried disabling all the plugins and gone back to default theme but looks like the solution is not plugin or theme dependent. Unfortunately nothing works! I am using wordpress 3.2.1

3 Answers 3

19

Try this one instead.

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

Yours is for things like category feeds if I recall correctly.

Based on link coolsaint provided you could remove both and then explicitly add back in the posts feed. It isn't the most elegant, but it does mean you don't have to modify the core WP files.

add_action('wp_head', 'addBackPostFeed');
function addBackPostFeed() {
    echo '<link rel="alternate" type="application/rss+xml" title="RSS 2.0 Feed" href="'.get_bloginfo('rss2_url').'" />'; 
}
5
  • 1
    the hook will remove my posts and comment feed both. I want only comment feed to be removed.
    – coolsaint
    Aug 25, 2011 at 17:53
  • I think you are out of luck then. Looking at codex (line 1591) phpxref.ftwr.co.uk/wordpress/nav.html?_functions/index.html - there is no callback and none of the args allow you to choose which of the two is displayed.
    – mrtsherman
    Aug 25, 2011 at 18:06
  • 1
    I have stumbled upon this page and gave me and workout and it worked wordpress.org/support/topic/…
    – coolsaint
    Aug 25, 2011 at 18:16
  • @coolsaint - thank you for the link. I added it to my answer as a workaround.
    – mrtsherman
    Aug 25, 2011 at 18:33
  • Why are the priorities 2 and 3? (Not familiar with priorities enough to know)
    – Mattypants
    Oct 6, 2016 at 6:28
11
remove_action('wp_head', 'feed_links_extra', 3 );
remove_action('wp_head', 'feed_links', 2 );

Adding this code to functions.php will remove all elements from your site that are related to RSS/Feeds.

Please Note: Before you remove this element from your site, make sure you know what this element is and why it is used. If you have lot of subscribers, then you may not want to delete this element.

2
  • I needed both lines of code to remove those links on my sites. So this answer was the best for me. Dec 15, 2014 at 20:20
  • Wow. Works like a charm after everything failed. Jan 20, 2015 at 14:46
5

This is an old question, but it appears that there are now filter hooks which can switch each feed independently (as you can see by examining the feed_links function code):

// add to functions.php
// display only main (not comments) feed links
function return_false() {
  return false;
}

add_filter('feed_links_show_comments_feed', 'return_false');
1
  • 1
    Since version 3.0 WordPress already have its own __return_false() function, there is no need to define an additional one. Oct 12, 2021 at 20:42

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.