[WordPress] Couldn't Edit Category from Admin Panel, So Resolved by Updating Database
This site is operated using WordPress, but a problem occurred where I couldn’t edit specific categories from the admin panel.
In the WordPress admin panel, the error message “間違えましたか? この項目を編集する権限がありません。” (Are you cheating? You do not have permission to edit this item.) was displayed and I couldn’t edit the category, so I’ll introduce the steps I took to resolve this by directly updating MySQL database values.
When I tried to edit the Amazon category from the WordPress admin panel, the message “間違えましたか? この項目を編集する権限がありません。” (Are you cheating? You do not have permission to edit this item.) was displayed and I couldn’t update it.
Since I couldn’t edit the category from the WordPress admin panel this time, I’ll directly edit the values stored in the MySQL database.
First, let’s confirm where WordPress category data is stored.
WordPress stores both categories and tags in the wp_terms table, so I’ll check these values.
wp_terms Stores basic information for terms used in post and link classification (categories and tags)
This time, I’ll change the record with category name wp_terms.name = Amazon and slug name wp_terms.slug = amazon to category name Amazon Web Services and slug name aws.
mysql> SELECT * FROM wp_terms WHERE name LIKE 'aws%';
+---------+---------+---------+------------+------------+
| term_id | name | slug | term_group | term_order |
+---------+---------+---------+------------+------------+
| 375 | aws-cli | aws-cli | 0 | 0 |
| 391 | AWS | aws-2 | 0 | 0 |
+---------+---------+---------+------------+------------+
2 rows in set (0.00 sec)
When I checked with SQL, there was a tag called aws-2, which wasn’t directly related to this task, but it would create duplicate pages with negative SEO impact, so I deleted it from the WordPress admin panel.
Next, I’ll check the wp_terms records for category names containing the string amazon.
mysql> SELECT * FROM wp_terms WHERE name LIKE 'amazon%';
+---------+---------------------+---------------------+------------+------------+
| term_id | name | slug | term_group | term_order |
+---------+---------------------+---------------------+------------+------------+
| 9 | Amazon | amazon | 0 | 0 |
| 120 | Amazon EC2 | ec2 | 0 | 0 |
| 121 | Amazon S3 | s3 | 0 | 0 |
| 144 | Amazon SES | amazon-ses | 0 | 0 |
| 258 | Amazon Appstore | amazon-appstore | 0 | 0 |
| 360 | amazon s3 | amazon-s3 | 0 | 0 |
| 891 | amazon payment | amazon-payment | 0 | 0 |
+---------+---------------------+---------------------+------------+------------+
7 rows in set (0.01 sec)
The inconsistency between having and not having the amazon- prefix is concerning. This isn’t related to the current issue, but I’d like to standardize it to one format separately.
I’ll specify the specific category term_id = 9 and update the values in the wp_terms table.
mysql> UPDATE wp_terms SET name = 'Amazon Web Services', slug = 'aws' WHERE term_id = 9;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
This concludes the story of how I couldn’t edit a WordPress category from the admin panel and resolved it by directly updating the MySQL database.
That’s all from the Gemba.