How to Expire Posts or Partial Post Content in WordPress
There are always times when you are running a time sensitive deal on your site that you want to expire. Often those posts live in a category like News or Contests, but there are times when you don’t want that. What if there was a way to get rid of the post entirely? What about just getting rid of part of the post content? Well in this article, we will share two plugins that can let you expire posts or partial post content in WordPress.
How to Expire Posts in WordPress?
There are ways to customize the loop with PHP codes and utilize custom fields to make this happen. But that sounds way too complicated. So we will be using a plugin called Post Expirator.
First thing you need to do is install and activate it. Then when you open your posts write panel, you will see a field like this:
You can enable the post expiration in there and select the date and time.
You are probably wondering what happens to the post once it is expired. You have two options, you can either change the status from Published to Draft or completely delete them. This option can be selected from the additional settings page that can be found under Settings » Post Expirator
In the options page, you also have the ability to show when the post will expire to your users. Currently this plugin only supports the content type “posts” and “page”.
How to Expire Partial Post Content in WordPress
The above method shows how to expire the entire post, but in some cases that is not what you want. You probably just want to remove some part of the post after a certain time. Well in that case, the plugin called CF Expiring Content Shortcode is your best solution.
Download and Install the plugin. Once you have done that, there are no additional settings. Simply wrap your content in the shortcode and set the date/time you’d like it to expire – once that time is eclipsed, it will no longer appear.
The date format is anything that can be parsed by PHP’s strtotime function. A few examples:
- [expires on="2010-10-01"]Expires on October 1, 2010[/expires]
- [expires on="Jan 3, 2011"]Expires on January 11, 2011[/expires]
- [expires on="12/3/2012 23:16:00"]Expires on December 2, 2012 at 11:16pm[/expires]
- [expires on="2015-01-01 + 15 days"]Expires on January 16, 2015[/expires]
Any of these methods would work. Just wrap your content around this shortcode.