您对如何创建cron有任何建议,这将使我这样做?
我有一个XML文件,可以定期更新汽车出售。简而言之,如果汽车已出售并且不再可供购买,则不再将其写入XML文件。为了确保该汽车不再在网站上可用,我创建了一个ACF字段,如果价值大于零,则表示该汽车可用。如果自定义字段的值小于一个或空的值,则表明汽车不再可用。
是否有一种方法可以在不再包含有关汽车的XML文件后立即清空此ACF字段?
Do you have any advice on how to create a cron which will allow me to do so?
I have an XML file that updates periodically with cars for sale. Simply put, if the car has been sold and is no longer available for purchase, it is no longer written to the XML file. To ensure that the car is no longer available on the site I created an ACF field that, if valued with a value greater than zero indicates that the car is available. If the custom field has a value less than one or is empty, this indicates that the car is no longer available.
Is there a way to get cron job to empty this ACF field as soon as the XML file no longer contains the car in question?
发布评论
评论(1)
WordPress拥有自己的CRON系统,用于调度任务,例如检查更新,安排发布帖子以及从垃圾桶中删除评论。所有Cron工作均由WP-Cron处理。
在您的情况下,您可以编写一个脚本或功能,该脚本或功能将在特定时间后在 wp-cron 的帮助下运行,以检查XML文件是否不再包含相关汽车。然后它将清空ACF字段。
您可以使用称为 documentation
WordPress has its own cron system for scheduling tasks such as checking for updates, scheduling a post for publication, and deleting comments from the trash. All cron jobs are handled by WP-Cron.
On your case you can write a script or function that will run after a specific time with the help of the WP-Cron to check if the XML file no longer contains the car in question. Then it will empty the ACF field.
You can do it using a plugin called WP Crontrol. To know about the use of the plugin please check this documentation