You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unable to delete pattern category that contains zero patterns #84865
A user reported that they had removed all the patterns from a category but it still appears when editing a pattern in the "Add category" UI and they could not find a way to delete the category that now has zero patterns associated with it.
Observe that you can see the new pattern category in Appearance > Editor > Design > Patterns (At this stage, you could delete the new pattern via the three dot menu on the top right)
Edit the pattern again and remove it from the new category
You will no longer see the pattern category in the list and cannot delete the category via the UI so there is no way to delete
If you interact with the Add Category search box while editing a pattern, you will still see the category with Zero patterns when you begin typing the category title
Screenshots, screen recording, code snippet
Pattern View without EMPTY category
Pattern edit screen that still shows EMPTY category under Add category
The delete option that is shown when you can interact with a category that contains one or more patterns.
Environment info
WP 7.1 playground
Twenty Twenty Five theme
Mac / Chrome
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
Please confirm which theme type you used for testing.
Thanks for the report. I looked at why this happens in current trunk (6b45881), by reading the code only. I have not reproduced it in a running Site Editor.
Why the empty category can't be deleted
The Delete action lives in the "Actions" menu on the category's own page, and an empty user category can't reach that page or that menu:
usePatternCategories only keeps categories with a non-zero count ("Filter categories so we only have those containing patterns"), for theme-registered and user-created categories alike: use-pattern-categories.js#L73-L77
CategoryItem renders nothing when count is falsy, so the item is not shown in the sidebar even though the server-side view_list includes empty user categories ('hide_empty' => false): category-item.jsx#L11 and view-config-api.php#L374
PatternsActions looks the category up in the filtered list and only renders the Rename/Delete menu if it is found, so the menu doesn't appear even if you open the category URL directly: actions.jsx#L14-L22
The "Add category" field in the pattern editor lists all terms of wp_pattern_category, which is why the empty category still shows up there.
So a user-created category whose last pattern was removed ends up orphaned: it still exists as a term, but nothing in the UI can reach it to rename or delete it.
Question on the intended UX
Before anyone writes a fix, which direction would the team prefer?
A) Keep empty user-created categories in the Patterns sidebar (e.g. shown with a count of 0) so they can be opened and deleted, while still hiding empty theme/core-registered categories.
B) Keep hiding empty categories in the sidebar, but allow deleting a category from somewhere else (for example from the category selector when editing a pattern).
C) Remove a user category automatically when its last pattern is removed from it.
A looks like the smallest change (the hook and CategoryItem need to treat user categories differently from registered ones), but I'm happy to follow whichever direction you prefer. I also noticed the sidebar was recently moved to the view config (#76823) and #82569 touches the same area, so I'd like to avoid conflicting with that work.
I'm interested in working on this if the direction is agreed.
I was able to reproduce the described issue & judging from the categories getting hidden in Patterns panel. Ideally they should also not show up on Add Category input. So a fix might be needed.
Peeking at #53287 & the Issues/PRs it links. Can't find any discussion on what the ideal flow should be for empty custom categories.
But we can have two flows:
Delete the category from db, that way it won't show up in Add category input (we'll also need to redirect user to All patterns category once the last pattern from selected category is deleted, as currently we stay there with a "No results" message from the dataview)
Just remove the pattern entry & keep category as-is like current behavior but then we'll also have to show the empty ones on Patterns page with an option to manually delete the category (option already exists).
Activity
Peerapatfc commentedon Oct 16, 2026
Thanks for the report. I looked at why this happens in current
trunk(6b45881), by reading the code only. I have not reproduced it in a running Site Editor.Why the empty category can't be deleted
The Delete action lives in the "Actions" menu on the category's own page, and an empty user category can't reach that page or that menu:
usePatternCategoriesonly keeps categories with a non-zero count ("Filter categories so we only have those containing patterns"), for theme-registered and user-created categories alike: use-pattern-categories.js#L73-L77CategoryItemrenders nothing whencountis falsy, so the item is not shown in the sidebar even though the server-sideview_listincludes empty user categories ('hide_empty' => false): category-item.jsx#L11 and view-config-api.php#L374PatternsActionslooks the category up in the filtered list and only renders the Rename/Delete menu if it is found, so the menu doesn't appear even if you open the category URL directly: actions.jsx#L14-L22The "Add category" field in the pattern editor lists all terms of
wp_pattern_category, which is why the empty category still shows up there.So a user-created category whose last pattern was removed ends up orphaned: it still exists as a term, but nothing in the UI can reach it to rename or delete it.
Question on the intended UX
Before anyone writes a fix, which direction would the team prefer?
A looks like the smallest change (the hook and
CategoryItemneed to treat user categories differently from registered ones), but I'm happy to follow whichever direction you prefer. I also noticed the sidebar was recently moved to the view config (#76823) and #82569 touches the same area, so I'd like to avoid conflicting with that work.I'm interested in working on this if the direction is agreed.
yashjawale commentedon Oct 16, 2026
Thanks for reporting the issue!
I was able to reproduce the described issue & judging from the categories getting hidden in Patterns panel. Ideally they should also not show up on Add Category input. So a fix might be needed.
Peeking at #53287 & the Issues/PRs it links. Can't find any discussion on what the ideal flow should be for empty custom categories.
But we can have two flows: