<?php
function bauen_pagination($pages = '', $range = 2)
{ 
 $showitems = ($range * 2)+1;  

     global $paged;
     if(empty($paged)) $paged = 1;

     if($pages == '')
     {
         global $wp_query;
         $pages = $wp_query->max_num_pages;
         if(!$pages)
         {
             $pages = 1;
         }
     }   

     if(1 != $pages)
     {
        echo "<div class='row'><div class='col-md-12 text-center'><ul class='bauen-pagination-wrap align-center mb-30 mt-30'>";
		echo "<li><a class='prev-link' href='".get_pagenum_link(1)."'><i class='ti-angle-left'></i></a></li>";
         
         for ($i=1; $i <= $pages; $i++)
         {
             if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
             {
                 echo esc_attr(($paged == $i))? "<li><a href='#' class='active'>".$i."</a></li>":"<li><a href='".get_pagenum_link($i)."'>".$i."</a></li>";
             }
         }
        echo "<li><a class='next-link' href='".get_pagenum_link($pages)."'><i class='ti-angle-right'></i></a></li>";  
        echo "</ul></div></div>\n";
     }
}
?>