I think there used to be an out-dated plugin to do this. Is there any way to do this easily with just a little code? We prefer not to rely on a plugin since that makes us dependent on the developer to keep it up-to-date.
We only have two parent categories we would like to remove for all of their child-category permalinks: “items” and “genres” (so it could be tailored to just removing two category IDs)
I see that there was a solution with the individual posts here, but I don’t think this works with the category permalinks as well, does it ?
This code pretty much does the job for this question and another one about removing the /category/ base from the permalinks. Got it from a plugin that does this, and decided to just use the raw code.
So the permalinks only have the lowest child-category listed.
First, we had:
example.com/category/items/books/
and now…
example.com/books
The RSS feeds, however, don’t seem to work with this shorter url, and still require the long-form url. (Not sure if there’s a fix for that.) Also, it doesn’t change the post permalink. It’s just the category permalink that changes. Paste the code below into your functions.php file. I’m using WordPress 3.0+.