This one is not a good way to do it but it’s easy to implement
global $post;
$original = $post;
$next = get_next_post(true);
$prev = get_previous_post(true);
$post = $next;
next_post_link();
$post = $original;
next_post_link();
// display current post
previous_post_link();
$post = $prev;
previous_post_link();
$post = $original;
To make the code more efficient, you can copy the respective functions from core code in “wp-includes/link-template.php” & then modify them as required
At the most basic level, in get_adjacent_post
, change LIMIT 1
to LIMIT 2
& $wpdb->get_row
to $wpdb->get_results
, then all other function which directly/indirectly use this function will be changed accordingly
NOTE: Don’t change the core code, instead copy the functions to your theme/plugin, rename them, modify them, then use the new functions to display the links