query, $pagination_query->query_vars ); // If max_num_pages is not already set, add it. if ( ! array_key_exists( 'max_num_pages', $query_args ) ) { $query_args['max_num_pages'] = $pagination_query->max_num_pages; } // If post_status is not already set, add it. if ( ! array_key_exists( 'post_status', $query_args ) ) { $query_args['post_status'] = 'publish'; } // Make sure the paged value exists and is at least 1. if ( ! array_key_exists( 'paged', $query_args ) || 0 == $query_args['paged'] ) { $query_args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : ( get_query_var( 'page' ) ? get_query_var( 'page' ) : 1 ); } // Encode our modified query. $json_query_args = wp_json_encode( $query_args ); // Set up the wrapper class. $wrapper_class = 'pagination-type-' . $pagination_type; // Indicate when we're loading into the last page, so the pagination can be hidden for the button and scroll types. if ( ! ( $query_args['max_num_pages'] > $query_args['paged'] ) ) { $wrapper_class .= ' last-page'; } else { $wrapper_class .= ''; } ?>