WordPress:计划的类别更改(工作流程)。怎么办?
我认为这是一个常见的情况:我分为三类:过去、当前、即将到来。
现在我写一篇关于下个月活动的文章。我把这篇文章放在即将发布的类别中。
我想要的是预定的类别更改。
即:
此活动从12月1日到12月10日。从现在到11月30日,这篇文章属于即将发布的类别(我在创建这篇文章时选择了这个类别)。
12 月 1 日,该帖子将自动位于“当前”类别中,直到 12 月 10 日。12
月 11 日,该帖子将自动位于“过去”类别中。
我搜索了一下,没有找到这样的插件。
基本上,我希望发布页面有两个额外的选项:
选项 1:更改为类别 _ on _
选项 2:更改为类别 _ on _
这听起来像是一个工作流程问题。我搜索了与工作流程相关的插件,但仍然没有运气。
关于如何实施这个有什么建议吗?我可以写一个插件,但我是 WP 新手。有人可以建议我使用哪些 API/函数吗?
谢谢你!
I think it is a common case:I have three categories: Past, Current, Upcoming.
Now I write a post about next month's event. I put this post in Upcoming category.
What I want is a scheduled category change.
i.e.:
This event runs from Dec 1 to Dec 10. From now till Nov 30, this post is in Upcoming category (I select this category when creating this post).
On Dec 1, this post will be in Current category automatically, till Dec 10.
On Dec 11, this post will be in Past category automatically.
I did a search and did not find such plug-in.
Basically, I want the publishing page to have two extra options:
Option 1: Change to Category _ on _
Option 2: Change to Category _ on _
It sounds like a workflow question. I searched workflow related plugin but still with no luck.
Any suggestion on how to implement this? I can write a plugin but I am new to WP. Could anybody suggest me which API/functions to use?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先:可能有一个插件可以处理您想要实现的目标。如果您需要一个简单的事件日历,我几乎可以肯定这可以使用现有插件来完成。在我的脑海中, MyCalendar 就是这样一个插件。在您自己编写代码之前,您可能需要搜索 wordpress 插件目录以获取更多选项。
话虽这么说,如果您无法避免自己构建这个,因为您的情况是专门的,那么这应该让您开始:
要么使用 自定义字段添加开始和结束日期的额外元数据或使事件成为自定义帖子自己的类型。详细解释自定义帖子类型的使用超出了简洁的答案的范围。
如果您选择添加两个名为 start 和 end (或类似名称)的自定义字段的更简单方法,则必须通过您的 cronjob 运行 php 脚本。服务器或使用 WP-Cron 函数 将当前时间与开始时间进行比较结束日期和相应地更改类别。
为了向您提供一些有用的代码(这些代码将进入您自己编写的插件),以下 php 片段应该为您指明正确的方向:
几点说明:
$first_time
必须是 UNIX 时间戳First off: There could be a plugin out there that can handle what you want to achieve. If you need a simple events calendar, I am almost certain this can be done with existing plugins. Off the top of my head, MyCalendar would be one such plugin. You might want to search the wordpress plugin directory for further options, before you dive into coding this on your own.
That being said, if you can't avoid constructing this yourself, because you're case is to specialized, this should get you started:
Either use custom fields to add the extra meta-data of start and end date or make the events a custom post type of their own. Explaining the use of custom post types en detail is past the scope of a concise SO answer.
If you opt for the simpler way of adding two custom fields called start and end (or the like), you will have to either run a php script as a cronjob via your server or make us of the WP-Cron Functions to compare the current time with the start and end date and change the category accordingly.
To provide you with some useful code (which would go into your self-written plugin), the following php snippet should point you in the right direction:
Few notes:
$first_time
has to be a UNIX timestamp