0

Afaik we can exclude content type, or individual node from XML Sitemap. But, is there anyway to exclude nodes with specific taxonomy term?

(for example excluding nodes with "longlivethetroll" tag)

Thank you.

0

You can use hook_xmlsitemap_element_alter() to check if the node has a particular taxonomy term & exclude it.

function MYMODULE_xmlsitemap_element_alter(&$element, $link, $sitemap) {
  // Check if link is a node link
  if ($link['type'] == 'node') {
    $node = node_load($link['id']);

    // Code to check if $node has taxonomy term goes here
    if ($node has taxonomy term) {
      $element['disabled'] = TRUE; // This removes the node link from sitemap
    }
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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