admin管理员组文章数量:1023815
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.
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.
本文标签: functionsAuto remove tags on certain date
版权声明:本文标题:functions - Auto remove tags on certain date 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745577800a2157127.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论