Okay
  Print

Infinite next and previous post looping in WordPress?

Read more: https://gist.github.com/banago/5603826

Code for Post: 

/**
 *  Infinite next and previous post looping in WordPress
 */
if( get_adjacent_post(false, '', true) ) { 
    previous_post_link('%link', '← Previous Post');
} else { 
    $first = new WP_Query('posts_per_page=1&order=DESC'); $first--->the_post();
        echo '<a href="' . get_permalink() . '">← Previous Post</a>';
      wp_reset_query();
}; 
    
if( get_adjacent_post(false, '', false) ) { 
    next_post_link('%link', 'Next Post →');
} else { 
    $last = new WP_Query('posts_per_page=1&order=ASC'); $last->the_post();
        echo '<a href="' . get_permalink() . '">Next Post →</a>';
    wp_reset_query();
};

Code for Custom Post Type:

/**
 *  Infinite next and previous post looping in WordPress
 */
if( get_adjacent_post(false, '', false) ) { 
    next_post_link('%link', '← Previous project');
} else { 
    $last = new WP_Query('post_type=project&posts_per_page=1&order=ASC'); $last->the_post();
    echo '<a href="' . get_permalink() . '">← Previous project</a>';
    wp_reset_query();
}; 
if( get_adjacent_post(false, '', true) ) { 
    previous_post_link('%link', 'Next project →');
} else { 
    $first = new WP_Query('post_type=project&posts_per_page=1&order=DESC'); $first->the_post();
    echo '<a href="' . get_permalink() . '">Next project →</a>';
    wp_reset_query();
};