How to remove core taxonomy rss feeds I'm creating my own custom taxonomy rss feeds and have added those sucessfully to the head on term pages. Now, however, I need to remove the core taxonomy feed from those pages (currently it shows 2 feeds: the custom feed and the core feed).

Many people have suggested simply using the taxonomy view which overrides the core term and feed displays, but for complex reasons I can't use this solution.  

I need to programmatically remove the feed from the head.

The original feed in the page head looks like this:

&lt;link rel="alternate" type="application/rss+xml" title="RSS - termname" href="/taxonomy/term/2764/0/feed"&gt;


My best attempt to remove this is done in template.php and shown below, but it doesn't work:

mytheme_preprocess_page(&amp;$variables) {
  //target taxonomy term pages
  if(arg(0) == 'taxonomy' &amp;&amp; arg(1) == 'term' &amp;&amp; is_numeric($arg2)) {
    $variables['head'] = preg_replace('/&lt;link rel="alternate" type="application\/rss\+xml" title=".*?" href=".*?"&gt;/', '', $variables['head']);
  }
}


I probably need to get even more specific on the 'href' portion as well, so it only removes the term feed...but I haven't gotten that far yet.

I also tried adding $variables['head'] = drupal_get_html_head(); at the end just to reload the head, in case it was necessary, and that doesn't help.

How can I programmatically remove this feed?
If you're using D7 hook_html_head_alter is your friend.

something like

function my_html_head_alter(&amp;$head_elements) {
  foreach ($head_elements as $key =&gt; $element) {
    if (isset($element['#attributes']['type']) &amp;&amp; $element['#attributes']['type'] == 'application/rss+xml') {
      unset($head_elements[$key]);
    }
  }
}


Otherwise your attempt seems to be the best solution. Perhaps try ungreedy regex?

&lt;link rel="alternate" type="application\/rss\+xml" title="[^"]*?" href="[^"]*?"&gt;