query, $wp_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'] = $wp_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'] ) { // The page that will be loaded $query_args['paged'] = 1; } // Only show if we have more pages to load if ( $query_args['max_num_pages'] > $query_args['paged'] ) : // Encode our modified query $json_query_args = wp_json_encode( $query_args ); ?>