Find out total number of pages in global query on archive page?

I’m trying to find out whether there is more than one page of posts (I’ve set my posts per blog page to 5 in the reading settings) in a custom category template.

I would think the global query would have the total number of pages as a property but I can’t find the call to it.

Related posts

Leave a Reply

2 comments

  1. To this day, Mridul Aggarwal answer is not only valid, but vital to use the_posts_pagination() function in some loops scenarios

    global $wp_query;
    the_posts_pagination();