Code Snippets: Getting The Page Number in WordPress

I’m pretty sure I didn’t create this function, but it was one I used over two or three iterations of my site in order to display a page indicator in the style of “1 of 48.”

Pretty simple code:

function get_pagination(){
  // $paged - number of the current page - WordPress variable
  global $paged, $wp_query;
  // How many pages do we have?
  if ( !$max_page ) {
    $max_page = $wp_query->max_num_pages;
      $paged = 1;  
  if($max_page > 1){
     echo ''.$paged.' of '.$max_page.'';

Not much else to say about it, but it has been useful from time to time.