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:

<link rel="alternate" type="application/rss+xml" title="RSS - termname" href="/taxonomy/term/2764/0/feed">

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

mytheme_preprocess_page(&$variables) {
  //target taxonomy term pages
  if(arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric($arg2)) {
    $variables['head'] = preg_replace('/<link rel="alternate" type="application\/rss\+xml" title=".*?" href=".*?">/', '', $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?


2 Answers 2


Have you tried the RSS Permissions module? Here is a quote about it (from the module's project page):

Set role-based permission settings for blog, taxonomy, aggregator, and main site's RSS feeds. This module does not disable RSS feeds altogether: RSS feeds created through the Views module and others not listed here do not have associated permissions.

RSS permissions module lets you disable some or all RSS feeds based on different user roles, and was created as a stopgap solution for #28337: Add permissions to disable RSS feeds.

This module adds role-based permission settings to blog, taxonomy, aggregator, and main site's RSS feeds.

  • 1
    This isn't a bad solution but I'd rather do it programatically...installing a module for this one purpose on a site that already has a ton of modules isn't ideal. I'll consider this a 'last resort'.
    – Feature
    Commented Jun 22, 2012 at 15:31

If you're using D7 hook_html_head_alter is your friend.

something like

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

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

<link rel="alternate" type="application\/rss\+xml" title="[^"]*?" href="[^"]*?">
  • Unfortunately it's D6 :(
    – Feature
    Commented Jun 21, 2012 at 16:47
  • Then you could use hook_menu_alter as RSS Permissions does and disable $items['taxonomy/term/%'] (drupalcode.org/project/rss_permissions.git/blob/refs/heads/…) Commented Jun 21, 2012 at 17:06
  • Yeah I started to reverse engineer what that module is doing and it may be a good solution. It gets weird because the callbacks are the same for both the term and feed pages.
    – Feature
    Commented Jun 22, 2012 at 15:32

Your Answer

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

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