Horje

You have to call setup_postdata($post) .

get_next_post() and get_previous_post() depend on calls to a number of properties in the global $post variable which is populated by calling setup_postdata($post) or the_post() . If $post is empty it returns null.


More Solution
Reffered: https://wordpress.org/