In WordPress pagination, max_num_pages may be set to 0 and the expected number of pages cannot be retrieved. This may happen because the WP_Query parameter is set to 'no_found_rows' => true.
If the no_found_rows parameter is set to true, WordPress will not count all posts, resulting in the max_num_pages value not being retrieved correctly.
To resolve this issue, you should check to see if the no_found_rows parameter is set to true and change its setting if necessary.