Remove Category from Slug
Strip "category" from post archive URL slugs in WordPress
by Paul Faulkner · github.com/headwalluk/remove-category-from-slug
Install
The author publishes release zips, so WP-CLI can install straight from GitHub:
wp plugin install https://github.com/headwalluk/remove-category-from-slug/releases/download/v1.0.1/remove-category-from-slug.zipReadme
Remove Category from Slug
A small, dependency-free WordPress plugin that strips the /category/ base from category archive URLs.
/category/news/ → /news/
/category/parent/child/ → /parent/child/
/category/news/page/2/ → /news/page/2/
/category/news/feed/ → /news/feed/
Old /category/... URLs are 301-redirected to the new form, so links and SEO carry over.
No settings page, no telemetry, no third-party SDKs. The whole plugin is a single file.
How it works
Three WordPress rewrite hooks do all the work:
init— overrides the category permastruct to%category%soget_category_link()returns the bare slug.category_rewrite_rules— rebuilds the rule set, emitting root, paged, and feed rules per category. Parent slugs are joined with/. A catch-all rule maps any leftover/<old_base>/...request into acategory_redirectquery var.request— seescategory_redirectand issues a 301 to the new URL.
Rewrite rules are flushed automatically on activation, deactivation, and whenever a category is created, edited, or deleted.
If Yoast SEO is active, the wpseo_canonical filter re-points category-archive canonical URLs at the bare slug too, since Yoast computes its own canonical rather than using core's. The filter is a no-op when Yoast is not installed.
Installation
- Copy the plugin folder to
wp-content/plugins/. - Activate it from the Plugins screen.
Development
PHP_CodeSniffer with WordPress Coding Standards:
phpcs # Check
phpcbf # Auto-fix
phpcs # Re-check
See CLAUDE.md for architecture notes and project conventions.
License
GPL-2.0-or-later. See LICENSE.
Read the full README on GitHub →