Opened 3 years ago
Last modified 5 weeks ago
#59667 new enhancement
Edit Category Screen: Improve error message when trying to update a category with an existing slug
| Reported by: | plari | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Taxonomy | Version: | 6.3.2 |
| Severity: | minor | Keywords: | has-patch |
| Cc: | Focuses: |
Description
Request: improve the error message shown on the Category Edit screen when trying to set an already-used slug.
Why:
If I edit a category and try to give it a slug that is already used on another category, I encounter the vague error Category not updated.
This error is not very informative.
By comparison, if I Quick-Edit to make this change, though, I am told: The slug “example-slug” is already in use by another term., which is much clearer and I understand the problem right away.
Attachments (1)
Change History (2)
This ticket was mentioned in PR #13963 on WordPress/wordpress-develop by @wpnomad.
5 weeks ago
#1
- Keywords has-patch added
On the Edit Term screen, saving a term with a slug already used by another term in the same taxonomy shows only "Category not updated.", while Quick Edit shows the underlying error.
This PR:
- Redirects with a new message index (
7) whenwp_update_term()returnsduplicate_term_slug. Other errors still use message5. - Adds message 7 to the
_item,categoryandpost_tagarrays: "Category not updated. The slug is already in use by another category." etc. - Makes the message lookup fall back to the generic
_itemmessage when a taxonomy's messages (set viaterm_updated_messages) don't define the requested index. Without this, taxonomies registering their own message arrays (e.g. WooCommerceproduct_cat) would show no notice at all for message 7.
Only a fixed message index goes in the URL; no user input is reflected.
Testing instructions
- Create two categories, e.g. "News" (
news) and "Updates". - Edit "Updates" on the full edit screen and set its slug to
news. Click Update. - Before: "Category not updated." After: "Category not updated. The slug is already in use by another category."
- Repeat for tags.
- Regression checks: a normal save still shows "Category updated."; clearing the name (bypassing
required) still shows "Category not updated.". - Optional: register a custom taxonomy with
term_updated_messagesentries lacking index 7; a duplicate slug shows "Item not updated. The slug is already in use by another term."
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Investigation, implementation, tests and local verification, under my direction.
---
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.
🤖 Generated with Claude Code
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Recording of the different error messages