Hi,
I know this has been asked before but I could not get any solution working and since I'm a newbie Grav user, I'm probably missing something very obvious.
I want to make the haywire home.twig file display the latest three blog posts, but not only from /blog (as in the original theme) but from all blogs that I have on the page.
ROOT
|-blog1
| |-post1
| '-post2
'-blog2
|-post1
'-post2
I have tried the following (copied from the top of the home.html.twig file)
{% extends 'partials/base.html.twig' %}
{% block content %}
{% set all_blogs = page.collection({
'items': '@root.descendants',
'order': {
'by': 'date',
'dir': 'desc'
}
}).ofType('blog')
%}
Then trying to use
{% for post in all_blogs.children.slice(0, 3) %}
Which yields no entry at all.
Also, trying any selection like
{% for post in pages.parent.template('blog').children.slice(0, 3) %}
does not work. Nor does
{% for post in page({'items':{'@taxonomy':{'template': 'blog'}}}).children.slice(0,3) %}
All these snippets were tried in the aforementioned twig file. Is that the correct place?
Also, my debug bar does not work, so I am struggling on multiple ends 🤔
Any help is highly appreciated.
Kind Regards,
Christian