I have inherited a WordPress site, where I'm trying to resolve a weird-looking issue related to post categories.
In the Edit Post
page, there is nothing showing up under Categories
(Gutenberg editor).
Thinking this is strange, I went to the Categories
page. There, I saw many categories with the same slug.
This is even more strange to me, since I thought categories couldn't have the same slug. I figure this is where the issue lies.
So I'd like to start deleting these duplicate categories, but there is no Delete
link – only View
.
Can anyone shed some light on what might be happening here? Can I fix this directly in the database somehow?
I have inherited a WordPress site, where I'm trying to resolve a weird-looking issue related to post categories.
In the Edit Post
page, there is nothing showing up under Categories
(Gutenberg editor).
Thinking this is strange, I went to the Categories
page. There, I saw many categories with the same slug.
This is even more strange to me, since I thought categories couldn't have the same slug. I figure this is where the issue lies.
So I'd like to start deleting these duplicate categories, but there is no Delete
link – only View
.
Can anyone shed some light on what might be happening here? Can I fix this directly in the database somehow?
Just to note: There will not be a delete option on a category on the Category page if posts are assigned to that category. (Added see below.)
If you want to delete a category, you have to first change those posts to another category. You can do this on the Posts page, sort by category, then a Quick Edit to change the category.
Once there are categories without posts, then you can delete that category.
Changing the values in the table may cause other problems. Probably not severe, but I would guess that you have many posts without categories because you deleted those items in the table.
Added
Apparently the current version of WP allows you to delete categories that have posts assigned.
I recall that not being the case in prior version - 4.9-ish - but cannot tell the exact version. It was within the last year, though.
Answer modified with this new information.
I found a few rows in the wp_terms
table with a term_id
of 0
.
There was also some entries in wp_term_taxonomy
with term_taxonomy_id
and term_id
both set to 0
.
After deleting all of those rows, behaviour returned to normal.
Also, I had to fix some issues with the database structure. In the wp_terms
table, I had to make sure that AUTO_INCREMENT
was enabled for the primary key field.