0

I'm using in single post template simple navigation below the post content:

$next_post = get_next_post();
        if($next_post) {
        $next_title = strip_tags(str_replace('"', '', $next_post->post_title));
        echo "\t" . '<a rel="next" href="' . get_permalink($next_post->ID) . '" title="' . $next_title. '" class=" ">'. $next_title . '<i class="fa fa-chevron-right"></i></a>' . "\n";
        }

and similar for get_previous_post(). Problem is, when next (or previous) post status is future, get_next_post() returns NULL. I simply need it working regardless of post status.

  • 1
    Posts that have the status future, aren't published, so there isn't a link to them. They don't exist publicly. Why would you want to do this anyway? If you're trying to use the post date as a date for a future event or something, that's not the way to do it. – Jacob Peattie Feb 22 at 8:58
  • I know showing "future" post is against logic, but it is still post, only with different status. Yes, I've got it like tricky solution to list future events - user have to just fill the date, and all those events (it's custom post type) are listed in proper order, and will disappear when their date is gone. Everything works fine, except these prev (next) post links. Example: link – Ondřej Vala Feb 22 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.