There are no functions for that in WordPress core (yet), however, you can:
- Use
get_previous_post()
to get the previous post. - Use
get_next_post()
to get the next post. - Or you can also make a direct call to
get_adjacent_post()
which is used by the above functions.
And then just use get_permalink()
to get the previous/next post’s URL.
For example:
$post = get_post(); // get the current post
$next_post = get_next_post(); // or use get_adjacent_post( false, '', false, 'category' );
$next_post_url = $next_post ? get_permalink( $next_post ) : '';
$prev_post = get_previous_post(); // or use get_adjacent_post( false, '', true, 'category' );
$prev_post_url = $prev_post ? get_permalink( $prev_post ) : '';