最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

functions - Auto remove tags on certain date

programmeradmin1浏览0评论

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
Add a comment  | 

1 Answer 1

Reset to default 0

You 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.

发布评论

评论列表(0)

  1. 暂无评论