I am trying to create next and prev links based on an a date entered as an ACF. This is what I have so far. It works but it is still based on the date the past was created vs. the ACF date with the slug event_date:
`if( get_adjacent_post(false, ”, true) ) {
previous_post_link(‘%link’, ‘« Previous Post’);
} else {
$first = new WP_Query(‘posts_per_page=1&order=DESC&meta_key=event_date&orderby=meta_value’); $first->the_post();
echo ‘<a href=”‘ . get_permalink() . ‘”>« Previous Post</a>’;
wp_reset_query();
}; ?>
<span class=”pipe”>|</span> <a href=”/”>Home</a> <span class=”pipe”>|</span>
<?
if( get_adjacent_post(false, ”, false) ) {
next_post_link(‘%link’, ‘Next Post »’);
} else {
$last = new WP_Query(‘posts_per_page=1&order=ASC&meta_key=event_date&orderby=meta_value’); $last->the_post();
echo ‘<a href=”‘ . get_permalink() . ‘”>Next Post »</a>’;
wp_reset_query();
};