Can WordPress show posts based on a button that the user clicked 2 pages back?

There are multiple ways of doing this.

  1. Use a session.
    Set a session and update your session value each time the filter has changed by the user.
    Check out PHP sessions.

  2. Use a cookie.
    Set a cookie and update your cookie value each time the filter has changed by the user.
    Check out PHP setcookie.

  3. Update user_meta (if users are registered users).
    When your users are registered users, you can set and update a user_meta value each time the user changes the filter.
    Check out add_user_meta and update_user_meta.