diff --git a/modules/metarefresh/lib/MetaLoader.php b/modules/metarefresh/lib/MetaLoader.php
index db67e9554cbaece060e934ba058cfc081eaaf8c5..ed6bdca66f0e884d7450b3b276b3e04dfa6c2fb1 100644
--- a/modules/metarefresh/lib/MetaLoader.php
+++ b/modules/metarefresh/lib/MetaLoader.php
@@ -161,14 +161,24 @@ class sspmod_metarefresh_MetaLoader
 			$template = null;
 			if (array_key_exists('template', $source)) $template = $source['template'];
 
-			$this->addMetadata($source['src'], $entity->getMetadata1xSP(), 'shib13-sp-remote', $template);
-			$this->addMetadata($source['src'], $entity->getMetadata1xIdP(), 'shib13-idp-remote', $template);
-			$this->addMetadata($source['src'], $entity->getMetadata20SP(), 'saml20-sp-remote', $template);
-			$this->addMetadata($source['src'], $entity->getMetadata20IdP(), 'saml20-idp-remote', $template);
-			$attributeAuthorities = $entity->getAttributeAuthorities();
-			if (!empty($attributeAuthorities)) {
-				$this->addMetadata($source['src'], $attributeAuthorities[0], 'attributeauthority-remote', $template);
-			}
+			if (in_array('shib13-sp-remote', $this->types)) {
+                    $this->addMetadata($source['src'], $entity->getMetadata1xSP(), 'shib13-sp-remote', $template);
+            }
+            if (in_array('shib13-idp-remote', $this->types)) {
+                    $this->addMetadata($source['src'], $entity->getMetadata1xIdP(), 'shib13-idp-remote', $template);
+            }
+            if (in_array('saml20-sp-remote', $this->types)) {
+                    $this->addMetadata($source['src'], $entity->getMetadata20SP(), 'saml20-sp-remote', $template);
+            }
+            if (in_array('saml20-idp-remote', $this->types)) {
+                    $this->addMetadata($source['src'], $entity->getMetadata20IdP(), 'saml20-idp-remote', $template);
+            }
+            if (in_array('attributeauthority-remote', $this->types)) {
+                    $attributeAuthorities = $entity->getAttributeAuthorities();
+                    if (!empty($attributeAuthorities)) {
+                            $this->addMetadata($source['src'], $attributeAuthorities[0], 'attributeauthority-remote', $template);
+                    }
+            }
 		}
 
 		$this->saveState($source, $responseHeaders);