|
Post by account_disabled on Jan 31, 2024 8:04:49 GMT
本文是与SiteGround合作创建的系列文章的一部分。感谢您对合作伙伴的支持,使 SitePoint 成为可能。 WordPress 提供了一个修订系统,可以在保存时记录每个页面和帖子的完整副本。优点:您可以随时恢复到文档的早期版本并进行比较。或者您可能会发现谁该为拼写错误和语法错误负责。 默认情况下,每页或每篇文章存储的修订数量没有限制。(请注意,每个编辑器的每个帖子只会进行一次自动保存 - 最近的自动保存会覆盖前一个。)每个修订都需要在 WordPress 的表中占据单独的行,并且可能需要在和表posts中包含多个条目。对于较小的站点来说,这很少是问题,但它可能会影响较大安装的性能和效率。表最终会充满永远不会被使用的冗余数据。 限制修订 修订次数可以在 WordPress 的wp-config.php文件中设置。如果您不知道该文件,我建议您向开发人员寻求进一步的指导。在编辑之前复制wp-config.php,因为最小的错误都可能会破坏您的 WordPress 网站。 要完 WhatsApp 号码数据 全禁用修订,请将以的早期版本并进行比较。或者您可能会发现谁下行添加到要限制修订,请将数字更改为正整数,例如每页/帖子不超过十个修订: define('WP_POST_REVISIONS', 10); 要恢复为无限制修订,请删除该行或将值更改为-修订插件 如果文件编辑感觉有点太硬核,有几个插件可以控制修订。例如,WP Revisions Limit以相同的方式设置修订限制。 以编程方式限制修订 该wp_revisions_to_keep过滤器允许插件或主题的functions.php文件来控制给定帖子保留的修订数量。滤器的函数传递两个参数: 要保留的默认修订数量 WP_Post当前帖子的对象 并且必须返回允许的修订数量。 以下示例为类型为“custom_post”的帖子设置了五个修订的限制您还可以使用WordPress REST API列出、检索和删除修订版本。 如何删除旧版本 上述方法会立即激活,因此,理想情况下,您应该WP_POST_REVISIONS在安装 WordPress 后立即进行设置。但是,该设置不会从 MySQL 数据库中删除旧版本。可以清除旧数据,但请注意危险。在采取任何行动之前,请记住 备份您的数据库! 最简单的选择是使用WP-Optimize等插件,它通过删除修订和其他优化来清理 WordPress 数据库。
|
|