get_next_posts_link not working without parameter max_num_pages July 2, 2022 by Tarik Billa Try to use this to get max_num_pages in searchpage.php global $wp_query; $wp_query->max_num_pages;