There’s probably a better way to ask this. I’m working on a blog, using an ever-so-slightly modified loop from the Kirby Starter Kit for the main page:
I want another loop that -only- shows the latest five posts in a small “Recent Posts” list, but isn’t effected by the pagination, so when I go to page 2, the main list is filtered to the next 5 posts, while this smaller list only shows the most recent 5.
This is my first Kirby project. I’m sorry if this is a stupid noob question.
The best place to add this logic is in a controller, if you are using the Starter Kit you already have it, look at site/controllers/blog.php. You can change it to get the latest 5 articles and store the result in a separate variable before doing the pagination:
And instead of putting the code for the recent articles directly into the blog template, put it in a snippet (e.g. recent-articles.php), which you can then include in your template like this:
I love you people. Thank you! Kirby as an experience has been amazing, but I gotta say the community has been amazing too. Thanks so much for the help!
Note @pedroborges blog controller as well. I missed a change he made moving the pagination control out of the initial “$articles” = business and my new loop was also being changed by pagination. Follow their suggestions exactly and it’s perfect!