pagination for custom post type archive page

You’re using $query-> but there is no variable named $query, it’s just pulled out of thin air, it has to come from somewhere, so PHP is generating notices complaining about it. It would be like if I answered the question with “you need to apply gabobobobble” or some other made up word.

So instead, look up next_posts_link:

https://developer.wordpress.org/reference/functions/next_posts_link/

The official docs say the second parameter is:

$max_page

  • (int) (Optional) Max pages. Default 0.

Since it’s optional you can remove it.