好吧,这对我很有用:
首先运行下面的脚本,生成用于草稿帖子的所有文件的文件位置。
SELECT voybp_posts.guid
FROM voybp_posts
WHERE voybp_posts.ID IN (SELECT voybp_postmeta.meta_value
FROM voybp_postmeta
WHERE voybp_postmeta.post_id IN (
SELECT voybp_posts.ID
FROM voybp_posts
WHERE voybp_posts.post_status="draft")
AND voybp_postmeta.meta_key="_thumbnail_id")
将其导出为CSV文件并保存到桌面,然后使用记事本++或类似程序使用查找/替换将rm添加到每行的开头。
下一步SSH进入服务器并执行rm命令。
接下来,修改上述脚本并运行它以删除数据库中没有任何结果的附件文件。
DELETE
FROM voybp_posts
WHERE voybp_posts.ID IN (SELECT voybp_postmeta.meta_value
FROM voybp_postmeta
WHERE voybp_postmeta.post_id IN (
SELECT voybp_posts.ID
FROM voybp_posts
WHERE voybp_posts.post_status="draft")
AND voybp_postmeta.meta_key="_thumbnail_id")
最后,我们找到并删除草稿帖子。
DELETE
FROM voybp_posts
WHERE voybp_posts.post_status="draft"
AND voybp_posts.post_type="post"
希望这有帮助