开发者

Remove Wordpress Comment Feed Link from header

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 wordpre开发者_开发问答ss 3.2.1


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').'" />'; 
}


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.


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜