Hi there!
I’m trying to exclude from my sitemap all the page that have a specific template.
Here my snippet:
(the template that I want to exclude is “form-item”
<?= '<?xml version="1.0" encoding="utf-8"?>'; ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php foreach ($pages as $p): ?>
<?php if($p->template() !== 'form-item'): ?>
<?php if(!strpos($p->url(), '/orders')): ?>
<?php if (in_array($p->uri(), $ignore)) continue ?>
<url>
<loc><?= html($p->url()) ?></loc>
<lastmod><?= $p->modified('c', 'date') ?></lastmod>
<priority><?= ($p->isHomePage()) ? 1 : number_format(0.5 / $p->depth(), 1) ?></priority>
<template> <?= $p->intendedTemplate() ?></template>
</url>
<?php endif ?>
<?php endif ?>
<?php endforeach ?>
</urlset>