wp_query->max_num_pages always returns 0 on custom post type
Yuo can also do it this way, count published posts, get settings posts per page, then divide. $published_posts = wp_count_posts()->publish; $posts_per_page = get_option(‘posts_per_page’); $page_number_max = ceil($published_posts / $posts_per_page);