The following snippet will let you set up post expiration code for WordPress website.

Snippet Source/Credit: nrbet.com