I have a custom post type events and am displaying these events using archive-events.php and single-events.php from the template hierarchy. I have a custom query in archive-events.php
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$events_query = new WP_Query( array (
'post_type' => 'events',
'orderby' => 'meta_value',
'meta_key' => '_fulldate',
'order' => 'ASC',
'paged' => $paged,
'meta_query' => array ( array(
'key' => '_fulldate',
'value' => $cutoff_date,
'type' => 'numeric',
'compare' => '>' ) ) )
);
This displays the events in order of event date ( as opposed to published date ). All works fine until I put previous_post_link()
and next_post_link()
into single-events.php. What happens then is that the next and previous links take me to the next and previous event by published date as opposed to by event date.
I am a bit confused about how events-single.php is meant to know which is the next event. Should I be doing some kind of query on there as well, because I'm not at the moment? It's just a standard 'single' file.
Could anybody help me out I have been up and down this and cant find out how to do it.