Only show pagination when post count exceeds show post

Total number of pages is $query->found_posts divided by $per_page_default. If the current page number is less than that amount, there are more pages.

post_count isn’t the total amount of posts, as the answer on the question you linked states, it’s the total number of posts on that single page only. That’s not going to tell you anything except maybe that you’re on the last page if the number happens to be less than total per page, but will fail if the total is divisible without remainder.

error code: 521