Filter post list by tag param


I’ve read the cookbook page for tag filtering by url param but can’t get it to work with my code below:

<?php foreach($list = $page->children()->listed()->flip()->paginate(6) as $post): ?>
<?php endforeach ?>

Example URL:


Any pointers would be appreciated.


You should really do this in a controller and follow the documentation. I.e. define the $list depending on whether or not a parameter is set or not.

Then use the variable in your template.

In your template:

<?php foreach($list as $post): ?>
<?php endforeach ?>

The $list variable must be defined in the controller using the code examples from the cookbook.

1 Like

Thanks, will read the controller docs :slight_smile: