Hello,
How can I auto expire published post in a specific category. I have a category called sponsored but I want each article published in this category to auto expire (revert to draft or trash) after 30 days. A 30 day expiry time stamp will be applied immediately to every post published into the sponsored category. Please I don’t mean that all post in the sponsored category should expire at the same time, because the post are being published at different times, so the time stamp is applied per post.
Thanks
Hello Tosin,
Thank you for posting. It can be doable using the WordPress Cron features. You can check the documentation here.
https://codex.wordpress.org/Function_Reference/wp_schedule_event
All you need to do is
Step 1: Setup a cron job which runs daily one time.
Step 2: With callback function get all the posts form your categories whose published date is older than 30 days.
Step 3: Update post statusOr check this plugin
https://wordpress.org/plugins/post-expiration-date/
Regards
Ravi- This reply was modified 5 years, 4 months ago by Ravi.
You must be logged in to reply to this topic.