I did not test this, but this should do what you want. Put the following in your functions.php
:
add_filter('rewrite_rules_array', 'new_category_name_rewrite_rule');
function new_category_name_rewrite_rule($rules) {
$new_rules = array();
$categories = get_categories();
foreach ($categories as $category) {
$cat_name = preg_replace('#\s+#', '-', $category->name);
$new_rules["https://wordpress.stackexchange.com/".$category->slug."https://wordpress.stackexchange.com/"] = "https://wordpress.stackexchange.com/".urlencode($cat_name)."https://wordpress.stackexchange.com/";
}
return $new_rules + $rules;
}
Related Posts:
- Mod_Rewrite to show only last subcategory in URL
- How do I use the same post slug for different Categories?
- Plural Category Base Slug On Category Archive Page
- Duplicate Category and Page URL loads Category instead of the Page
- wordpress sub-category ( lowercase letters + non-latin characters ) = 404
- The default code for “posts_nav_link” on category.php isn’t working
- Read GET parameters in APACHE Mod Rewrite rules for WordPress categories in Posts
- Removing subcategories from permalinks [duplicate]
- A different permalink structure for different categories
- How to remove category name for only one category?
- Include a page’s “category” in its URL
- Hide category name using mod_rewrite
- hierarchical taxonomy in permalinks? using same slug
- How to get category slug link? ( include parent categories)
- How to add custom prefix before category base for category page URL?
- Remove parent category from permalink? Basically only have the child category?
- How to get permalinks with category base working with sub-categories
- Use category base slug in posts’ permalink
- Category archive by year with permalink support /category/YYYY
- Filtering categories in the permalink structure
- Allow duplicate permalink slugs for posts in different categories
- Force WordPress to Show Pages Instead of Category
- How do I get the category URL from get_the_category?
- Multiple post categories – single permalink
- How to exclude uncategorized from permalink structure /%category%/%postname%/
- How to control which category will be picked for the slug of a post?
- Create terms when registering taxonomy?
- 404 error on subcategory pages
- Categories’ hierarchy in URL
- How to create non-unique sub-category slugs?
- Rewrite category slug
- Changing the category permalink structure
- Category links suddenly started giving 404 errors
- Add category to custom post type automatically, using category slug
- Best and Cleanest way to remove /category/ from category permalinks? [duplicate]
- Exclude subcategories from the url
- How to display only the parent category in the permalink
- Permalinks – Different structures for different categories?
- custom permalinks for category archive ( custom base and no parent slug )
- Return category slug / title from category ID
- New categories are now going to 404s
- Best way to programmatically link to multiple categories (union/intersection) [closed]
- Default category link for a custom category is a broken link
- wordpress wp_list_categories
- How to get category URL with the slug?
- Categories vs. Page Site Organization
- Possible to make a subdirectory that loops through a single category?
- Need to pull parent category and slug – only pulling daughter category
- WordPress subcategories return 404 in custom template
- force category base – archive pages work WITH & WITHOUT category base slug in url?
- How get permalink for the current category or tag?
- Categories showing page not found
- How to disable default category linkbuilding?
- Show parent category in URL of subcategory archive page
- Hide uncategorized when no category set
- How to rewrite the post URL according to the category?
- WordPress URL Rewrite for dynamic and customized URL
- A single category with a specific permalink structure differing from the standard set for the rest of the site
- Older entries link within category page
- How can you change the permalink for pages?
- Get posts from specific taxonomy term
- Get category URL knowing it’s id
- Hide the word ‘category’ from my permalinks
- Automatically redirect a page to a category that share the same slug
- How to Link to Most Recent Custom Post of Same Term
- Category url generate 404 error
- How to remove one specific category (uncategorized) from post permalinks
- Custom Permalink with child categories creating 404
- How do I retrieve the category ID (ugly permalinks) in my sub-navigation menu?
- Redirect year month day postname permalink structure to category postname structure
- How to remove the category from post slug
- url for posts for a date within a category
- Need help with major category and permalink re-organization
- How to use category slug with a regular page
- Different post slug based on archive
- Allow two posts (from different categories) to have the same slug
- How Can I Use Equal And Question Mark In Category Slug?
- Subcategories randomly not working after page/post/category edit in wordpress. Fix: saving permalinks twice
- How to prevent WordPress from redirecting single page to prefixed category archive with same name?
- Is it possible to set up blog categories without changing permalink structure
- How to 301 redirect from url with post id to permalink with post name (slug)?
- Subcategory Page 404ing
- Remove “category” from permalink with add_rewrite_rule
- Change the full slug for a specific category?
- Get category from slug list
- When category name and title are the same … WP will select archive.php instead of single.php
- Accessible Subcategory URL’s pages without using .php hack
- How to auto update post title and slug with category name when post status is updated
- Catch 404 after changing permalink structure from /%postname%/ to /%category%/%postname%/
- Group Posts by First Letter of Title categories
- Change category base based on category
- Allow duplicate permalink slugs for posts in different categories
- Changing Permalinks for Category Pages Only
- Link categories to last post
- How to include first assigned category in the post URL?
- How do I hide posts in a category from all listings but still allow the posts to be viewed?
- Custom permalinks structure
- Category archive page has two URLs even when default theme is active with no active plugins
- Use same wordpress category base and tags as the prefix as the post permalink
- How to remove the category from the url only for a specific category of articles on wordpress