Show all pages/posts by tag

Dear Community,

I am new to the Kirby community and started working with Kirby some time ago. Used to be an occasional wordpress user and no experienced programmer, but WOW I just fell in love with Kirby.

Now stuck with an issue, and searched the forum/cheat sheet but no luck so far.

Trying to show all blog posts in a blog template based on a specific tag. E.g. show all posts (title + url) with the tag ‘tools’, and for tag ‘design’, and for tag ‘review’, etc.

So far I haven’t been able to produce a solid workaround. Looking forward getting ideas from this great community. Thank you in advance for sharing your thoughts and ideas on this.

Have a look at the solution docs:

@texnixe Sonja, thank you for pointing out this reference. I have tried to implement the code from the page, but unfortunately I am a bit of a programming noob. Can’t seem to reproduce the right code for if/else and return/echo in relation to show posts by tags… :blush:

Solved, for anyone interested in sorting articles by tag, I have used the following code. Where ‘yourtag’ can be used to fill in the desired tag.

<?php $articles = $page->children()->filterBy('tags', 'yourtag', ','); ?>
  <?php foreach($articles as $article): ?>
  <a href="<?php echo $article->url() ?>"><?php echo $article->title()->html() ?></a><br/>
  <?php echo $article->date(l::get('date.format')) ?>
  <p><?php echo $article->text()->excerpt(220) ?></p>
<?php endforeach ?>