Some WordPress posts are like milk. That is, they are good when you first wrote them, this for a week (or less and maybe a year) later they become a bit obsolete and are no longer as useful. Items like seasonal announcements, event details, contests that have ended, giveaways, etc. In these cases, you may want to add an expiration date to make the contents of a publication which no longer has any reason to be displayed. This is what we will see in this tutorial.

When to expire content

There are two main reasons why you might consider adding an expiration date to posts / pages.

First of all, if your contents take time into account, this is a very good situation to add an expiration date. For example, if you are talking about a sale that expires in a week, then the post will no longer be available once the date expires.

Coupons, gifts, events… all of them are good reasons to add an expiration date.

But you can also use an expiration date to create an artificial shortage, even if your post doesn't really need an expiration date. The shortage adds a sense of urgency to contents of your post.

If you feel like you want to take the visiteurs don't act soon...they might miss the opportunity. And nobody likes to miss a good opportunity.

How to add a simple expiration date in WordPress

To add an expiration date on WordPress, I suggest a plugin free called “Simple Post Expiration”. Although there are a few plugins that also do the job.

To correctly configure the expirations on the plugin, you must perform two steps:

Set a global expiration date for your post

Use a shortcode to tell the plugin what to do with the content of your post after the expiration date.

1 - Set a global expiration date for your item

This first step is quite simple. Whenever you add or edit a publication, you will have new options in the section " Publish ". All you need to do is select the day you want your post to expire

New section publish wordpress tab

Then, when this date arrives, the plugin will automatically add text before the title of the publication indicating that the title has expired:

Post expired wordpress tutorial

You may need to translate the plugin, because at the moment it seems to me available only in English.

But while the plugin adds this text to the title of your post, it leaves the content of your post unchanged. At least so far.

To edit your content after a post expires, you can wrap the content you want to edit in a shortcode.

2 - Wrap expired content in a shortcode

To indicate the content you want to expire, you can use the short code [expires]. For example, here is how the default would work with my example above.

On the bottom, it would look like this:

Example of a post that expires wordpress

And it will output something similar to this:

Example of expired content

But the shortcode also allows you to customize the message that displays after a post expires. By adding expired = 'your message' to the shortcode, you can customize the message as you want.

For example, the use of the short code [expires expired = "Sorry, this content is no longer available"] will appear as follows:

Content with an article alert message that expires

This assumes that you can use the shortcode on some of your content.

That's all for this tutorial, I hope it will allow you to add articles that expire.