List pages and subpages having a specific tag

Hi there!

I’m having a hard time trying to list pages and subpages having a specific tag. My folder structure is:

professional-translation-services

  • inner-page-1
  • inner-page-2

I’m currently using this code:

<?php $items = $pages->listed()->filterBy('tags', 'solutions', ','); ?>

        <ul>
          <?php foreach($items as $item): ?>
            <li><a href="<?= $item->url() ?>"><?= $item->title()->html() ?></a></li>
          <?php endforeach ?>
        </ul>

However, it shows only the page ‘professional-translation-services’, and not the subpages. I checked and all the pages are listed and have the tag solutions.

What I’m missing here? Thank you.

You are filtering the wrong list of pages

$items = page('professional-translation-services')->children()->listed()filterBy('tags', 'solutions', ',');

Thanks. Is there a way to filter the pages that have a certain tag? No matter if they are children/parent/cousin/aunties? :slight_smile:

Throughout the site? Then you have to use $site->index(), not recommended when you have a really large site…

This works, thank you!