I have a list with long and short posts.
The short posts are not display in a single page because they are too short. I use an ACF field (checkbox type) to define short post : article_short
But when I'm in a single page who display a long post I would like to display the next/prev long post available.
I wrote :
$context['prev_next_posts'] = Timber::get_posts(array(
'post_type' => 'post',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'article_short',
'compare' => 'LIKE',
'value' => 0
)
),
'orderby' => 'date',
'order' => 'DESC',
'has_password' => FALSE
));
Short posts are well excluded.
In my twig file I attached my context :
{% if prev_next_posts.next %}
<a href="{{ prev_next_posts.next.link }}">{{ prev_next_posts.next.title }}</a>
{% endif %}
{% if prev_next_posts.prev %}
<a href="{{ prev_next_posts.prev.link }}">{{ prev_next_posts.prev.title }}</a>
{% endif %}
But nothing is display... Do you have any idea please ?
According to Timber documentation I tried to display post in the same category too with (true). Same result. Nothing is display.
https://timber.github.io/docs/reference/timber-post/#next
{% if prev_next_posts.next(true) %}
<a href="{{ prev_next_posts.next.link }}">{{ prev_next_posts.next.title }}</a>
{% endif %}
{% if prev_next_posts.prev(true) %}
<a href="{{ prev_next_posts.prev.link }}">{{ prev_next_posts.prev.title }}</a>
{% endif %}