I’m using get_next_post_link()
and get_previous_post_link()
within the loop but the returned posts are not correct.
get_next_post_link()
shows the previous post and get_previous_post_link()
gives the current post. Below the context of these links:
$args['name'] = $postname;
$query = new WP_Query($args);
if($query->have_posts())
{
while ($query->have_posts())
{
$query->the_post();
$id = get_the_ID();
$title = get_the_title();
$content = get_the_content();
$nextpost = get_next_post_link('Next: %link');
$previouspost = get_previous_post_link('Prev: %link');
}
}