I was wondering how could I automatically remove a tag from a post on a certain date? Let's say I have a tag called "upcoming", I would want functionality where I could type in a date and on that date, the tag would be removed.
So basically, have a tag, set date, when date is reached, remove tag.
Best,
Biot
I was wondering how could I automatically remove a tag from a post on a certain date? Let's say I have a tag called "upcoming", I would want functionality where I could type in a date and on that date, the tag would be removed.
So basically, have a tag, set date, when date is reached, remove tag.
Best,
Biot
Share Improve this question asked Apr 17, 2019 at 19:47 biotbiot 1 1- 1 One possible solution would be to use a cron job to check your posts custom date field and if its > today's date delete the tag. – RiddleMeThis Commented Apr 17, 2019 at 19:57
1 Answer
Reset to default 0You can use wp_schedule_event( int $timestamp, string $recurrence, string $hook, array $args = array() )
function to automatically remove the tag. This function will run automatically after the given interval. You can set the interval daily.
Daily the function will run and remove the tag from the post if current date is equal to certain date. You can also run it on hourly bases.
Please note that you have to write you function on the hook of schedule event that will check the date and remove the tag.