• Resolved Jon Masterson

    (@jonmasterson)


    I wanted to remove some page navigation at the bottom of the last page in my query, and only on the last page. I could not find the answer I needed from the docs or the forum, but I figured it out, and decided to post my solution should anyone else want to do this…

    To hide anything on the last page:

    <?php $p = (get_query_var('paged')) ? get_query_var('paged') : 1; // The Page Number ?>
    <?php if ($wp_query->max_num_pages > 1 && $wp_query->max_num_pages > $p) : ?> // only show if there is more than one page, and the page number is less than the total number of pages (the total number = the last page)
    // put whatever you're trying to hide here
    <?php endif; ?>

    If this has been covered before, my apologies…

  • The topic ‘Testing for Last Page in Query’ is closed to new replies.