Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Displaying Pagination with on Page Twig and HTML

Started by T. H. Wright 9 years ago · 0 replies · 1233 views
9 years ago

My site's homepage runs the following collection to display recent posts. How do I display the option to cycle forward and backward through the collection of recent posts?

Do I need a different Twig function that makes a call to the collection?

TWIG
{% set options = { items: {'@taxonomy.category': 'post'}, 'limit': 9, 'order': {'by': 'date', 'dir': 'desc'}, 'pagination': true } %}
{% set recent_posts = page.collection(options) %}

<ul>
    {% for p in recent_posts %}
    <li class="recent-posts" style="list-style: none"><strong><a href="{{ p.url }}">{{ p.title }}</a></strong><br>
        <span>{{ p.date|date("D, F d, Y") }} T{{ p.date|date("H:i:s A T") }}</span></li>
    {% endfor %}
</ul>

Suggested topics

Topic Participants Replies Views Activity
Content & Markdown · by Jochen, 11 months ago
6 987 11 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 786 1 year ago
Content & Markdown · by Jan L'Am, 2 years ago
4 695 2 years ago
Content & Markdown · by Leonardo, 2 years ago
3 618 2 years ago
Content & Markdown · by belthasar, 2 years ago
4 1001 2 years ago