Exclude posts from certain category breaks custom pagination

You will need to duplicate every instance of $wp_query and change it to $the_query. Example

global $wp_query, $the_query;

  /** Stop execution if there's only 1 page */
  if( $wp_query->max_num_pages <= 1 || $the_query->max_num_pages <= 1 )
     return;

EDIT

Here is the pagination function that I use. Have no time to code now or to really dig into your code. Change accordingly. $cat_query and $cpt_query are my variables that I use for my custom queries

function pietergoosen_pagination($pages="", $range = 2) {   
    $showitems = ($range * 2)+1;  

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

    if($pages == '') {
        global $wp_query, $cat_query, $cpt_query;
        if(is_page_template( 'page-pop.php' )) {
            $pages = $cat_query->max_num_pages;
            if(!$pages) {
                $pages = 1;
            }
        }elseif(is_page_template( 'page-cpt.php' )) {
            $pages = $cpt_query->max_num_pages;
            if(!$pages) {
                $pages = 1;
            }
        }else{
            $pages = $wp_query->max_num_pages;
            if(!$pages) {
                $pages = 1;
            }
        }   
    }   

    if(1 != $pages) {
        $string = _x( 'Page %1$s of %2$s' , '%1$s = current page, %2$s = all pages' , 'pietergoosen' );
        echo "<div class="pagination"><span>" . sprintf( $string, $paged, $pages ) . "</span>";
        if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href="".get_pagenum_link(1)."">" . __( '&laquo; First', 'pietergoosen' ) . "</a>";
        if($paged > 1 && $showitems < $pages) echo "<a href="".get_pagenum_link($paged - 1)."">" . __( '&lsaquo; Previous', 'pietergoosen' ) . "</a>";

        for ($i=1; $i <= $pages; $i++) {
            if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )) {
                echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href="".get_pagenum_link($i)."" class=\"inactive\">".$i."</a>";
            }
        }

        if ($paged < $pages && $showitems < $pages) echo "<a href="" . get_pagenum_link($paged + 1)."">" . __( 'Next &rsaquo;', 'pietergoosen' ) . "</a>";
        if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "<a href="".get_pagenum_link($pages)."">" . __( 'Last &raquo;', 'pietergoosen' ) . "</a>";
        echo "</div>\n";
    }
}