标题:wordpress 主题残留数据清理

发表于

wordpress安装主题再删除后,往往会有一些残留数据,需要自己在数据库里进行清理,否则wordpress后台的“管理网络-站点-编辑-设置”里边会有很多垃圾项目。清理方法如下:

第一步:在wp_1_options表里查找关键字theme相关的数据项
mysql> select option_id,option_name from wp_1_options where option_name like '%theme%';
+-----------+----------------------------------+
| option_id | option_name |
+-----------+----------------------------------+
| 2416 | theme_mods_iGoogler |
| 2415 | current_theme |
| 3219 | theme_mods_iGoogler-1.2.3 |
| 3220 | theme_switched |

第二步:检查每个主题名字相关的数据项,看是否可以被全部清理,比如已经删除的iGoogler主题
mysql> select option_id,option_name from wp_1_options where option_name like '%igoogler%';
+-----------+-----------------------------+
| option_id | option_name |
+-----------+-----------------------------+
| 2416 | theme_mods_iGoogler |
| 2417 | widget_igooglerwidget |
| 3219 | theme_mods_iGoogler-1.2.3 |
| 3222 | theme_mods_iGoogler-1.0 |
| 3604 | iGoogler_friendlink_display |
| 3605 | iGoogler_sch_btn_name |
| 3606 | iGoogler_homepage_keywords |
| 3607 | iGoogler_seach_keywords |
| 3608 | iGoogler_excerpt_first_p |
| 3609 | iGoogler_excerpt_length |
| 3610 | iGoogler_google_custom |
| 3611 | iGoogler_single_copyright |
| 3612 | iGoogler_copyright_content |
| 3613 | iGoogler_site_stat |
| 3614 | iGoogler_h3 |
| 3615 | iGoogler_navi_left |
| 3616 | iGoogler_navi_middle |
| 3617 | iGoogler_navi_right |
| 7201 | iGoogler_init |
| 7202 | iGoogler_google-plus-one |
| 7203 | iGoogler_google_plus_id |
| 7204 | iGoogler_bottom_ad |
| 7205 | iGoogler_respond_ad |
| 816056 | theme_mods_iGoogler-1.2.4 |
+-----------+-----------------------------+
24 rows in set (0.00 sec)

第三步:如果确认iGoogler主题残留的这些数据项都没用,可以全部删掉,则执行下边操作,如果发现不能全部删除,则需要按照option_id逐条删除。
mysql> DELETE from wp_1_options WHERE option_id IN ( select t.option_id from (SELECT option_id FROM wp_1_options WHERE option_name like '%igoogler%' ) t);
Query OK, 24 rows affected (0.00 sec)