wordpress自动发布

tech2023-01-23  111

wordpress自动发布

WordPress automatically creates revisions of your content. Whenever you save a post or a page, the old version is retained so you can revert back at any time. Older revisions are never deleted so you always have a full history of all page changes.However, sometimes it’s necessary to do a little housekeeping. Every revision requires a separate row in WordPress’s posts table and perhaps multiple entries in the postmeta and term_relationships tables. Removing older revisions will free up disk space and ease MySQL’s processing burden.

WordPress自动创建您内容的修订版。 每当您保存帖子或页面时,都会保留旧版本,因此您可以随时还原。 较旧的修订版不会被删除,因此您始终拥有所有页面更改的完整历史记录。但是,有时需要做一些整理工作。 每个修订都需要在WordPress的posts表中单独放置一行,并在postmeta和term_relationships表中可能需要多个条目。 删除较旧的修订版将释放磁盘空间并减轻MySQL的处理负担。

删除旧修订 (Removing old revisions)

I’m going to say this only once: BACK UP YOUR DATABASE! We’re about to run SQL statements directly on your MySQL tables and one tiny slip could trash your WordPress installation.First, you need to find your WordPress table prefix which is specified in the following line of wp-config.php:

我只说一次: 备份您的数据库! 我们将直接在MySQL表上运行SQL语句,一个小小的错误就可能破坏WordPress安装。首先,您需要找到wp-config.php的以下行中指定的WordPress表前缀:

$table_prefix = 'wp_';

wp_ is the default but it can be changed to give your installation a little additional security. We’ll assume wp_ has been specified in the following code.To delete all revisions for all pages and posts, start a MySQL administration tool such as phpMyAdmin and run the following SQL statement:

wp_是默认设置,但是可以更改它以为您的安装提供一些额外的安全性。 我们假设在以下代码中指定了wp_。要删除所有页面和帖子的所有修订,请启动MySQL管理工具(例如phpMyAdmin)并运行以下SQL语句:

DELETE a,b,cFROM wp_posts a LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) WHERE a.post_type = 'revision';

(Remember to change all table references from “wp_” to your table prefix if necessary.)

(必要时请记住将所有表引用从“ wp_”更改为表前缀。)

tip: SQL Shenanigans 提示: SQL Shenanigans

Many thanks to Michael Ambrosio for highlighting a subtle problem with this SQL statement which can cause WordPress links to be deleted. View his article for more information…

非常感谢Michael Ambrosio突出显示了此SQL语句的一个细微问题,该问题可能导致WordPress链接被删除。 查看他的文章以获取更多信息……

If that’s a little too severe, you could remove all revisions prior to a specific date, e.g. the following statement will remove all revisions except for those made after January 1, 2010:

如果这有点太严厉,则可以删除特定日期之前的所有修订,例如,以下语句将删除除2010年1月1日之后所做的所有修订:

DELETE a,b,cFROM wp_posts a LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) WHERE a.post_type = 'revision'AND a.post_date < '2010-01-01';

(Note that MySQL dates are specified using YYYY-MM-DD notation.)

(请注意,MySQL日期是使用YYYY-MM-DD表示法指定的。)

禁用或限制修订 (Disabling or limiting revisions)

Add the following statement to your WordPress wp-config.php file to permanently switch off post revisions:

将以下语句添加到WordPress wp-config.php文件中以永久关闭发布修订:

define('WP_POST_REVISIONS', false);

The value can be set to ‘true’ to re-enable revisions.Alternatively, you can use a positive integer to limit the number of permitted revisions, e.g.

可以将值设置为“ true”以重新启用修订。或者,您可以使用正整数来限制允许的修订数量,例如

define('WP_POST_REVISIONS', 5);

This will create a maximum of 5 revisions per post, plus one for auto-saving purposes. Older revisions will be automatically deleted.

每个帖子最多可创建5个修订,另外还有1个用于自动保存。 较旧的修订版将被自动删除。

WordPress插件 (WordPress plugins)

If this all sounds a little too scary, you’ll be pleased to know that there are a number of WordPress plugins offering revision control.Do you have any further tips for controlling WordPress revisions?

如果这一切听起来有点吓人,您会很高兴知道有许多提供版本控制的WordPress插件 。您还有其他控制WordPress版本的提示吗?

翻译自: https://www.sitepoint.com/configure-wordpress-post-revisions/

wordpress自动发布

相关资源:禁用WordPress的自动保存草稿文章修订功能方法详解
最新回复(0)