Query for combining posts on a WordPress multisite network and displaying a custom pagnition

This is the queried solution to the problem that also lists a way to display pagination, though I haven’t worked out how to run the pagination SEO just yet. I was not able to figure out how to use WP’s default pagination in this scenario.

If you have a suggest please let me know:

<?php

//Setting up a query
$query = new WP_Query($args);

//Listing all site ID's
$sites = array( 1, 2, 3 );

//Setting up empty array list
$all_posts = array();

//Querying all posts in the argument
$args = array( 'post_type' => 'post', 'order' => 'DESC');

// Looping all the sites and compiling posts in the array $all_posts
foreach( $sites as $site ) {
 switch_to_blog( $site );
 $posts = get_posts( $args );
 foreach( $posts as $post ) {
 // Better get the post's permalink, since it's site-dependent
 $post->permalink = get_permalink($post->ID);
 $all_posts[] = $post;
 }
 //restoring to the default blog
 restore_current_blog();
}

//sorting posts using the sort funtion
$all_posts = sort_posts($all_posts);

//manually setting the number of page articles
$nb_elem_per_page = 8;

//manually setting the $paged item
$page = isset($_GET['page'])?intval($_GET['page']-1):0;

//calculating the number of paged elements
$number_of_pages = intval(count($all_posts)/$nb_elem_per_page)+2;

?>

<div class="row">
 <?php

 $i = 1; // row item counter
 $m = 2; // default max per row

//displaying all posts with pagination to follow

 foreach( array_slice($all_posts,$page*$nb_elem_per_page,$nb_elem_per_page) as $post ){
 setup_postdata($post);
 //while ( have_posts() ) { the_post(); ?>
 <div class="col-md-6">
 <div class="item">
 <?php echo generateImage(get_the_post_thumbnail_src(get_the_ID(),'intro-image-small'),'',$post->permalink); ?>
 <div class="content">
 <?php get_template_part( 'assets/partials/default', 'info' ); ?>
 <h2><a href="<?php echo $post->permalink; ?>"><?php the_title(); ?></a></h2>
 <div class="text">
 <?php echo get_the_excerpt (); ?>
 </div>
 </div>
 </div>
 </div>
 <?php if($i==$m){ ?>
 <div class="clearfix"></div>
 <?php $i = 1; }else{
 $i++;
 }
 } ?>
</div>

<div class="pagination">
 <div class="numbers">
 <nav class="navigation pagination" role="navigation">
 <div class="nav-links">

 <?php if($_GET['page'] > 1){ ?>
 <a href='./?page=<?php echo $_GET['page']-1; ?>' class="page-numbers">Newer</a>
 <?php } ?>

 <?php
 for($i=1;$i<$number_of_pages;$i++){ ?>
 <?php if($i != $_GET['page']){ ?><a href='./?page=<?php echo $i?>' class="page-numbers"><?php }else{ ?><span class="page-numbers current"><?php } ?>
 <?php echo $i; ?>
 <?php if($i != $_GET['page']){ ?></a><?php }else{ ?></span><?php } ?>
 <?php } ?>

 <?php if($_GET['page'] < ($number_of_pages-1)){ ?>
 <a href='./?page=<?php echo $_GET['page']+1; ?>' class="page-numbers">Older</a>
 <?php } ?>

 </div>
 </nav>
 </div>
</div>

<?php wp_reset_query(); ?>