Post Expiration Period Add-on
Get to know how to set the post’s expiration date via the WordPress JetEngine form.
The Post expiration period add-on allows you to display a new post for a limited time. You also could set an expiration action so that a post would be deleted or change the status to draft after the date elapses. This feature works if you have limited-time offers for the customers on your site or want clients to publish posts that would be deleted, like, after a month. The expiration period can be added via the WordPress JetEngine form and set in the Insert/Update Post notification settings.
Install the Post Expiration Period
The first way to install the post expiration period is to get it via the latest update of the JetEngine plugin. Proceed to the JetEngine tab in WordPress Dashboard, and there you can find the post expiration period among external modules. Enable the toggle to activate the feature.
Another way to install the post expiration period is to download the add-on from the Crocoblock DevTools page, where this and other features are free. After that, navigate to Plugins on the Dashboard, click on the “Add New” button, then “Upload plugin.” After installing the Post expiration period plugin, activate it in the JetEngine dashboard by enabling the toggle.
Create a JetEngine Form
Since the expiration period can be set via the JetEngine form, you should create one.
To find out how to create a form, follow this tutorial.
Get through our other guide if you want to know more about form Notifications Settings, especially Insert/Update Post type.
Also, check out this YouTube video to learn how to create the Add New Post form.
When you set up a form for creating posts, proceed to the Insert/Update Post Notification and press to edit it. Check the box in the Enable expiration period block, and another two blocks will appear. In the Expiration period, enter the required number of days and choose where you want to move posts in the Expiration action radio – to Trash or Draft.
After setting the form up, don’t forget to hit “Apply Changes” and update the form.
Create a New Post with the Form
Add the form with the post expiration period to the page on the front end. To see the add-on in action, we have created a new post with the JetEngine form and set it up to move to Trash with an expiration of one day.
As we can see, the post has moved to the trash within 24 hours after creation.
Create Admin Columns
To display the post expiration date, you could add an Admin Column to the custom post type.
Go to the JetEngine > Post Types section in the WP Dashboard and open the CPT you want to work with.
Scroll the page down to the Admin Columns block. Click the “Add New” button and fill in the fields with appropriate data:
- In the Type field, choose the Custom Callback option from the drop-down list;
- In the Callback field, click the “Select from existing callbacks” line. In the appeared window, you need to choose jet_engine_custom_cb_date;
- In the next window, type _jet_pep_period in the “Set field” text area. After that, set the Format of time and date in the admin column;
Hit the “Apply” button and be sure to “Update Post Type.”
And now you can see that the admit column gets the data from the Expiration period form field and show when the post moves to Draft or Trash.
That’s all for the post’s expiration period. Now you know how to install the add-on, set it up in the JetEngine form, and check the expiration date with the admin column.