Here is what I did and I’ve fooled around with mine enough to where I think it works right. First some caveats:
1) I didn’t change any code inside the theme so this shouldn’t matter.
2) I don’t use subcategories so I don’t know if that works or not.
3) My permalink structure is set at /%category%/%postname%/ – if yours is different, you’ll probably need to tweak it, or it may work for you as well.
4) This isn’t a plugin (yet, I might get around to doing that but I have never written a plugin before and I wanted to get this out now). This means when you upgrade WordPress, you have to insert the code again.
So, here is the solution.
1) In wp-includes/category-template.php search for the following line of code:
$catlink = get_option('home') . user_trailingslashit($catlink, 'category');
Just below that, insert the following:
$catlink = str_replace('/category', "", $catlink);
2) In wp-includes/classes.php search for the following block of code:
if ( isset($error) )
$this->query_vars['error'] = $error;
Just below that, insert the following:
if (@$this->query_vars["name"] == "page")
{
$tmp_ar = $this->query_vars;
$this->query_vars = array();
$this->query_vars["paged"] = str_replace("/", "", $tmp_ar["page"]);
$this->query_vars["category_name"] = $tmp_ar["category_name"];
}
3) Finally, in your .htacces file, add the following to redirect your old /category/ URLs to your new ones (if your blog doesn’t reside in the root, you’ll have to tweak it):
RewriteRule ^category/(.+)$ http://www.domain.com/$1 [R=301,L]
If you do same as here, then I’m sure you will rock.
I have tried this on latest wordpress 2.8.4
Now back to setting up your nice blog 🙂
View Comments
thanks Ash...... can try Remove Category base too mate
https://wordpress.org/plugins/remove-category-base-littlebizzy/
no database so pretty fast... cheers bro
i really find this very necessary.
registry cleaners are really very useful specially if you are encountering registry errors on your windows xp machine ..
It is very interesting for me to read that article. Thanx for it. I like such topics and everything connected to this matter. I definitely want to read more on that blog soon.
David Stepman
very well
information you write it very clean. I'm very lucky to get this information from you.
yes, my next page is working, it dosent so any 404 error now.
Thanks
You cook a great recipes :D .
I’ve trying to make this hack before, but I never succeed. So now thanks for your recipes. I never think to use htaccess :D
Fantastic tip
I am used to install the “top level categories” plugin to do the same thing…