WordPress 常见错误整理

1 无法添加目录,提示:Could not insert term into the database

如果出现上述问题,可能有多种因素导致,以下是一些可以尝试的方案:
1)尝试修复数据表:
修改配置文件 wp-config.php,添加如下行:

define('WP_ALLOW_REPAIR', true);

运行:
http://yourwebsite.com/wp-admin/maint/repair.php

然后注释掉刚才添加的一行。

如果上述仍无法解决,尝试下一步。

2)检查数据库表结构:

ALTER TABLE `wp_terms` CHANGE `term_id` `term_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE wp_terms AUTO_INCREMENT = 1000;

上面的 1000 是随便设了一个值,建议你根据 wp_terms 实际已经有的条目来设定下一个增加值。

同时也有可能需要修改:

ALTER TABLE `wp_term_taxonomy` CHANGE `term_taxonomy_id` `term_taxonomy_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT;

3)是否添加了重复条目:
确保您尝试添加的条目在数据库中不存在。如果同名条目已经存在,WordPress将不允许插入重复条目。

2 PHP Warning: Constant FS_CHMOD_DIR already defined

如果出现这一警告,则可以将:

define('FS_CHMOD_FILE', 0644);

define('FS_CHMOD_DIR', 0755);

修改为:

if ( ! defined( 'FS_CHMOD_FILE' ) ) {
    define('FS_CHMOD_FILE', 0644);
}
if ( ! defined( 'FS_CHMOD_DIR' ) ) {
    define('FS_CHMOD_DIR', 0755);
}

3 PHP Warning: failed to open stream: No such file or directory (advanced-cache.php)

出现这一错误的可能原因是之前安装了类似 WP Super Cache、W3 Total Cache 等插件卸载后依然保留了一些配置。
可以尝试打开 wp-config.php 进行如下修改:
将:

define( 'WP_CACHE', true ); 

修改为:

define( 'WP_CACHE', false );

如果有其他类似路径设置,则注释掉:

// define( 'WPCACHEHOME', '/alidata/liuxiao.org/wp-content/plugins/wp-super-cache/' );
// define('W3TC_EDGE_MODE', true); // Added by W3 Total Cache

Add a Comment

Your email address will not be published. Required fields are marked *