Please read this topic for explanation: Idea: Remove 'Category Base' From Permalinks
This plugin adds a simple filter (which removes category_base text from permalinks) on get_pagenum_link, wp_list_categories and the_category functions. That's all :)
Basically, it turns your URL's from something like "http://yourdomain/category/news/" to "http://yourdomain/news/".
It is meant to be used together with Urban Giraffe's "Redirection" plugin and a few redirections already set up. If used by itself, you'll just get lots of "Error 404 - Not found" pages.
To see the end result, please visit wordpress.skyphe.org and browse around. You'll notice that no URL contains "category" and still everything works just fine.
Please read the provided "readme.txt" for installation instructions.
Important: If you're using Redirection plugin v1.x, please replace the pluses (+) in regexp with stars (*).
I recommend Redirection v2.x, please upgrade if possible.
Download Decategorizer v0.4 WordPress Plugin from:
Changelog:
September 13th, 2008:
v0.4 - plugin now checks if redirection tables exist (d'oh) before starting to work. It also checks whether adding redirections is actually needed (if you have no child categories, for example).
August 15th, 2008:
v0.3 - added automatic creation of redirection rules. PLEASE NOTE: Although I've been testing the plugin for the past two hours, do try it at home first. REMINDER TO SELF: addslashes(), INSERT, save your sanity...
August 5th, 2008:
v0.2 - added the filter to 'category_link' as well - sitemap generating plugins should no longer show '/category/' in site links.
earlier that day... :)
v0.1c - new regex which ignores comments, tags, authors and search: (?!^/[\d]{4}/|^/tag/|^/author/|^/search/|^/comments/)^/(.+)/page/([\d]+)/
August 4th, 2008:
I've updated the plugin in the WordPress plugin repository, please download it from there.
July 20th, 2008:
Everything's working fine now, thanks to some clarity in my mind today :)
The regexp is quite simple, actually: (?!^/[\d]{4}/)^/(.+)/page/([\d]+)/
Let's break it down:
The first part (?!^/[\d]{4}/) searches for a four digit string ([/d] = one digit, {4} = match 4 times exactly) with forward slashes (/) around it (as in year, like /2008/). The ^ sign positions the pointer at the beginning of the string and ?! means that, to continue, this expression must not be matched. So, in short, if it's impossible to match a four digit string surrounded with slashes at the beginning of the string, for example /2008/, only then we can continue with our regular expression. Otherwise, we'll assume that it's a date archive and move on.
The second part starts once again with ^, which is exactly what was missing from my previous attempts. We must position the pointer to the beginning of the string, match anything - (.+) = from one time to infinite number of times, or (.*) = from zero times to infinite number of times - that appears before /page/ (that means slashes too) and store it in backreference number 1 ($1).
The only thing left is to get the page number ([\d]+) and store it into backreference number 2 ($2).
Then we can call it all back and display as /category/$1/page/$2/.
Easy as a pie, right? :)
Please read the readme.txt and test on a local installation first, don't try it on live sites until you're absolutely sure that it works. It should work, but you can never be too cautious :)


WordPress “Decategorizer” plugin…
This plugin adds a simple filter (which removes category_base text from permalinks) on get_pagenum_link, wp_list_categories and the_category functions. That’s all :)
Basically, it turns your URL’s from something like “http://yourdomain/category/new…
i have to try this out. if it works as promised, i can get down to doing some things i’ve been postponing until future versions of wp.
thanks, much.
hi. Thanks for plugin
perfect.
Regards
I hope it works for you :)
Also, be sure to set the redirection method to simple / pass-through, that’s something I forgot to put in the first version of the readme file.
Feel free to post any questions here, I’ll try to help as much as I can.
I got my hopes up prematurely.
It seems that the regexps that I’ve provided work only if you have a 4 digit number between 1970 and 2020 in the beginning of your category name.
My apologies :/
So, I’ve spent the last couple of hours trying to come up with something else that would actually work like it’s supposed to, and I ended up with the following:
/(?![0-9][0-9][0-9][0-9][/])(.*)/page/(\d*)/
this code would replace all the previous regexp redirections that I’ve proposed.
where it fails is monthly and daily archives:
2008/page/2/ works just fine
2008/07/page/2/ and 2008/07/03/page/2/ do not.
I need a regex guru, it seems…
I can’t help out… but I will gladly wait by the sidelines and cheer you on. :)
Thanks, Joseph :)
I hope I’ll get it fixed by next week, there has been some progress.
Ok, if I’m not mistaken again, this should work flawlessly:
Source URL: (?!^/[\d]{4}/)^/(.*)/page/([\d]*)/
Target URL: /category/$1/page/$2/
Please check at http://wordpress.skyphe.org
thanks aesqe, will you update the file in WP-plug directory accordingly, soon??
I was rewriting the readme yesterday when I came upon a few issues I’d like to fix within the plugin itself, like adding the trailing slash to URLs without needing to modify the main index file. I’m almost done with it.
There’s also the problem with sitemap plugins - they will include “/category/” in URLs. Because this solution is a hack, I doubt that plugin authors would add a checkbox option to remove “/category/” from sitemap URLs, but who knows…
I’m hoping that WordPress team will fix this issue even before v3 comes out.
Here’s the current state of the readme.txt:
http://wordpress.skyphe.org/wp-content/plugins/decategorizer/readme.txt
I’ll finish the testing as soon as I can, but I’ve just started a new job and I’m really short on free time right now :/
Let me know if this works for you.
I have updated the files in the WordPress plugin repository, please download the archive from there.
Final regexp (hopefully), with tag, author, search and comments excluded. Sorry I didn’t think of it sooner:
(?!^/[\d]{4}/|^/tag/|^/author/|^/search/|^/comments/)^/(.+)/page/([\d]+)/
[...] to make it work. I’ve been testing it for the past few weeks and haven’t noticed any hickups. Read on.I’ve also switched from TinyMCE to WYMeditor and I’m liking it so far. You can download it as a [...]
So to make it work i MUST use the girafes redirection plugin? If so, would be there a possibility for some quick redirect trick, when i do not want to use it? (i guess it would be just one simple rule which would just cut the category_base)
P.S.: how about RSS links etc. - everything works?
P.S.: and what happens, when i got a page or single (using /%postname%] with the same name of the category?
to noname:
Yes, you must :) But it shouldn’t affect your site’s speed, if that’s your concern.
RSS links and sitemap links work just fine, no problems there.
When using just /%postname% as permalink structure (no trailing slash), you will see a category archive.
When using /%postname%/ (with trailing slash):
If a page with that name exists, you will see the page with that name.
If it doesn’t, you will see the post with that name.
If that doesn’t work for you, please leave another comment so I can see if there’s anything that could be done about it :)
I have updated the plugin today. V0.3 brings automatic creation of redirection rules for categories that have child categories.
As always, read the readme.txt and try it locally first ;)
thx, will try and let you know