You can try this SO question Pagination when using wp_query?
Notice that their example uses the $query
variable for the WP_Query
instance, while your code uses $the_query
.
Also notice that they use paged property in the array that is being passed into WP_Query