Skip to content

Instantly share code, notes, and snippets.

@tpitre
Last active September 20, 2022 13:35
Show Gist options
  • Save tpitre/19a264bc80f082e929bb24bde0d44534 to your computer and use it in GitHub Desktop.
Save tpitre/19a264bc80f082e929bb24bde0d44534 to your computer and use it in GitHub Desktop.
WP Timber/Twig Example Usage - Archive Twig Template
{# Pull in the layout wrapper #}
{% extends "@templates/_layout.twig" %}
{# Fill in the "content" block defined in _layout.twig #}
{% block content %}
<div class="c-content{{ content.classes ? ' ' ~ content.classes }} u-spacing--and-half u-space--bottom">
<div data-bp="container">
<div class="l-wrap">
{% include "@organisms/sections/headers/page-header.twig" with {
"page_header": {
"title": term.name,
"classes": "c-content__header",
"date": false
}
} %}
</div>
</div>
{#
THIS IS THE PART TO FOCUS ON:
- Card Grid include
- Accepts the "posts" variable set in the archive.php file which contains all WP post data
#}
{% include "@organisms/sections/feeds/card-grid.twig" with {
"card_grid": {
"posts": posts,
"classes": "c-content__feed"
}
} %}
</div>
<div data-bp="container">
<div class="l-wrap">
{% include "@molecules/navigation/pagination/pagination.twig" with { "pagination": posts.pagination } %}
</div>
</div>
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment