The TFT Unpublish Plugin allows you to set a date and time at which a Post, Page or Custom Post Type will be set back to Draft. Usage cases include:
- Automatically removing a Press Release from public view at a set time.
- Removing a ‘special offer’ page from public view when the offer expires.
- Removing any time sensitive material from the website
After installing and activating the Plugin, you will find a short configuration page under the ‘Toolsforthinking’ menu on the Admin dashboard. On opening this page you will see something like the following:
Posts and Pages are enabled as default, but can be disabled if you desire. You can enable or disable the settings on other Post types as you require.
Within an enabled post type, you will find a new input dialogue:
To enable the Unpublish on this particular object, check the ‘Enable Unpublish‘ checkbox. You can then select the date and time at which the object will be made Draft by clicking in to the ‘Unpublish on:‘ field and selecting the date and time using the Datepicker tool. The ‘Redirect URL‘ field allows you to specify a URL within your site – or an external URL – that will be displayed after the post become unpublished. This helps avoid 404 errors. If you don’t want the user to be redirected, simply leave this field blank.
When you have entered the details, Update the post.
On returning to the Admin List you will see the details of the update post changed to reflect the Unpublish data entered:
This plugin relies on WP-Cron or a ‘real’ cron job to work
Like any WordPress Plugin that runs ‘in the background’ the plugin assumes that the WP-Cron configuration on the website is working. This means that you either have enough traffic coming to the site to ensure that the WP-Cron system within WordPress works, or you trigger WP-Cron processing in WordPress using an external cron service.
The schedule slug is tft_unpublish_five_minutes and the check on whether to unpublish a post is run every 5 minutes.
The hook triggered by this schedule is called tft_unpublish_posts_cron_hook.
Manual Triggering
Should you wish to trigger the unpublish process manually or directly from a cron service, the URL to use is yoursite.com/?tft_trigger_unpublish=1 Note that this will only unpublish posts which have an expire date in the past.
Site Time Zone Setting
The plugin uses whatever time zone is set within WordPress Settings.