Can't display articles by tag

Hi all -

I’m trying to show 3 posts from my ‘projects’ category that match a certain tag name but I’m having trouble and wondered if someone could take a look at my code? Thanks so much

  <?php foreach($projects->limit(3) as $project): ?>

    <div class="col-lg-4 col-md-4 col-sm-12 project_box">
        <a href="<?= $project->url() ?>" class="project_name"><?= $project->title()->html() ?></a>
          <?php if($image = $project->images()->sortBy('sort', 'asc')->first()): $thumb = $image->crop(600, 400); ?>
            <a href="<?= $project->url() ?>"><img src="<?= $thumb->url() ?>" alt="Thumbnail for <?= $project->title()->html() ?>" class="responsive" /></a>
          <?php endif ?>

  <?php endforeach ?>

Where is $projects defined?

Sorry just above I have:

<?php $projects = $page->children()->filterBy('tagname'); ?>

There’s something missing:

<?php $projects = $page->children()->filterBy('name_of_tagsfield', 'tagname'); ?>

Thanks - yeah I had that first;

<?php $projects = $page->children()->filterBy('tags', 'tagname'); ?>

And here is the project.yml blueprint where tag field is defined

label: Tags
type:  tags

I don’t quite understand where the problem is or what exactly does not work as expected?

Hmm me neither. I’m simply trying to show the latest 3 articles under the ‘projects’ category and with a related tag on a ‘what we do’ page. But nothing shows and I get no error (debugging on)

Are you getting the right page? You are fetching the children of the current page, not the children of the projects page?

Am I? How do I change that?

Well, I can’t possibly know that. You just told me that you are on a “What we do” page. So to fetch the children of another page (e.g. a page called projects), you can’t use $page but have to use the page helper page('project').

Otherwise, if we don’t get anywhere, feel free to upload your project to Dropbox or whatever and PM me a link.