navigation - get_next_post() not working with future post status

admin2025-06-02  3

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.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748877036a314461.html

最新回复(0)