Wordpress:自动删除 x 天前的帖子? [英] Wordpress: automatically delete posts that are x days old?
本文介绍了Wordpress:自动删除 x 天前的帖子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
很长一段时间以来,我一直在寻找一个插件,可以删除超过特定年龄"(例如 30 天)的帖子.这样做的最佳方法是什么?
For a long time, I have searched for a plugin that will delete posts that are over a certain 'age' (eg. 30 days old). What is the best way to do this?
推荐答案
以下是一些 SQL,可以查找已发布 30 天或更长时间的所有帖子:
Here's some SQL that will find every post that has been around for 30 days or more:
SELECT * FROM `wp_posts`
WHERE `post_type` = 'post'
AND DATEDIFF(NOW(), `post_date`) > 30
要删除所有帖子,您可以将 SELECT * FROM
替换为 DELETE FROM
— 但请确保在执行此操作之前进行备份!
To delete all the posts, you can replace SELECT * FROM
with DELETE FROM
— but make sure you take a backup before you do this!
然后,您可以随意使用 cron
,可以是 shell 脚本、PHP 脚本或任何您最喜欢的脚本.
You can then just cron
that however you like, be that a shell script, a PHP script, or whatever you're most comfortable with.
这篇关于Wordpress:自动删除 x 天前的帖子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文