我可以访问.../page/1
,.../page/2
,etc
...,并且它显示帖子,因此我知道分页在技术上是可行的,但是分页链接未显示。
木材
use const Flynt\Archives\POST_TYPES;
global $paged;
if (!isset($paged) || !$paged){
$paged = 1;
}
$context = Timber::get_context();
$args = array(
'numberposts' => -1,'post_type' => 'event','meta_key' => 'start_date','orderby' => 'meta_value','order' => 'ASC','posts_per_page' => 6,'paged' => $paged
);
$context['events'] = new Timber\PostQuery($args);
$context['options'] = get_fields('options');
Timber::render('templates/classes-and-registration.twig',$context);
树枝
<ul class="pagination">
{% if posts.pagination.prev %}
<li class="page-item">
<a class="page-link" href="{{ posts.pagination.prev.link }}" aria-label="Previous">
<span aria-hidden="true">«</span>
<span class="sr-only">Previous</span>
</a>
</li>
{% endif %}
{% for page in posts.pagination.pages %}
<li class="page-item">
{% if page.link %}
<a class="page-link" href="{{ page.link }}">{{ page.title }}</a>
{% else %}
<span class="{{page.class}}">{{page.title}}</span>
{% endif %}
</li>
{% endfor %}
{% if posts.pagination.next %}
<li class="page-item">
<a class="page-link" href="{{ posts.pagination.next.link }}" aria-label="Next">
<span aria-hidden="true">»</span>
<span class="sr-only">Next</span>
</a>
</li>
{% endif %}
</ul>