4 ms·
Thanks man! But how do I loop through this content? ie How can I write a small widget with all the recent posts?
by GoodbyeEarl 10y ago
Thanks man! But how do I loop through this content? ie How can I write a small widget with all the recent posts?
- pedroborges 10y agoYou can do whatever you want on your templates. If by widget you mean reusable code, you could use a snippet. So this logic can go on a template or snippet: <?php $latest = page('blog')->children()->visible()->limit(6); ?> <div class="widget"> <?php foreach($latest as $post) : ?> <a href="<?= $post->url()?>"><h2><?= $post->title()->html() ?></h2></a> <?php endforeach ?> </div> Instead of fetching the post on the template, you could use a controller and just pass the $latest variable to the template.
- pedroborges 10y agoKirby doesn't output any markup, you have total control to over it :D The API for querying content is very powerful.