Add pagination to my custom loop [duplicate]

This should get the offset for you, and from there it’s a simple matter of adjusting your query

$offset = "0";
$no_of_posts = the_posts_per_page( false ); //Number of posts to display on each page
if (preg_match('/page/', $_SERVER['REQUEST_URI'])) {
    $uri = explode("https://wordpress.stackexchange.com/", $_SERVER['REQUEST_URI']);
    foreach ($uri as $key=>$value) {
        if ($value == "") {
        unset($uri[$key]);
        }
    }
    $offset = (array_pop($uri) * $no_of_posts) - $no_of_posts;
}