
Email This Post
How to remove category base from permalinks
Wordpress July 7th, 2007
Visited 4641 times, 4 so far todayLooking through the wordpress forums I saw a large number of people wanting to know how to remove ‘category base’ from permalinks. For example http://bloggerholic.com/category/wordpress/
I found the solution and it’s easy! This is only for Wordpress 2.0+
All you need to do is the following:
- Go to your wp-includes folder.
- find the template file called “category-template.php” and open the file in any text editor.
- Find the follwing line $catlink = $wp_rewrite->get_category_permastruct();
You will see this code two lines below function get_category_link($category_id) { - Below it add the following line $catlink = str_replace(’/category’, ”, $catlink);
NOTE:
Due to the font the code has changed, Please make a note to change the curly quotes into standard text quotes. - Save the file and upload “category-template.php” in wp_includes folder.
That’s it your done!
NOTE: Make sure you don’t name your page name the same as category name.
Go back to:Wordpress for Dummies
This book “Wordpress for Dummies” provides you with everything you need to get up and running with WordPress. The book covers blogging basics, choosing a hosting solution or setting up a host, developing blog content, syndicating blog posts with RSS, launching a specialized blog (including podcasting, photoblogging, mobile blogging, and videoblogging), and even earning revenue.
It Includes help on every aspect of installing and using WordPress, illustrations from real-world WordPress blogs, step-by-step tutorials on key topics, and insights from bloggers who have used WordPress
Read the Comments
[ # 31 ] Comment from Charlie [July 12, 2007, 8:40 pm]
[ # 32 ] Comment from Farida [July 13, 2007, 4:40 am]
Hi Charlie I created a sub-category on this site to test it and it worked fine for me. If you have copied the code from Kris (above) do not add the second quote. It should work by just adding this code $catlink = str_replace(’/category’, ”, $catlink);
Otherwise it could be a problem with the way your permalinks are set up.
Try that and let me know if you have problems.
[ # 36 ] Comment from Charlie [July 14, 2007, 10:49 pm]
Hello
I retried you code as you suggested and got this error which broke the page:
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /homepages/18/d96255924/htdocs/casino-heaven.eu/wp-includes/category-template.php on line 56
I had actually tried your tip before Kris posted his improvements and had the same problem - at which point I gave up.
I have to admit that there could be any number of conflicts with exiting plugins, which may be making the difference between this working or not.
I have got Filipe Fortes’s plugin Top Level Categories working which will do the job so I might just stick with that.
[ # 37 ] Comment from Farida [July 15, 2007, 10:16 am]
[ # 54 ] Comment from Aleksey [July 17, 2007, 7:18 am]
Hi Farida,
Could you please to clear up the mystery of how to make links for tags from tag cloud like “/tag/tag_name” or even “/tag_name” instead of “/index.php?tag=new”. I see your tag links are fine tuned and seo friendly… but mine, hrrrr.
No matter what I did, wp shows 404 error…
Will be appreciate for help!
Thanks
PS setting up utw options brings the same results - 404 - page not found
[ # 55 ] Comment from Farida [July 18, 2007, 9:32 am]
[ # 56 ] Comment from Aleksey [July 18, 2007, 11:49 am]
Farida,
the Options->Tags is not working for me and for many other users who installed the latest version of wp (2.2.1 I think). There lots of discussion around this problem, but nobody can find out a panacea.
People say it’s about some type of conflict between wp and utw code.
That is the exact what I say. Funny thing, but when you turn off the rewrite rule for categories and permalinks (fancy urls I think or smth like that) in wp options and that activate “use url rewriting for local tag urls …” the UTW rewrite function becomes working properly. But as soon as I turn on fancy url back utw stops working again.
I’m so confused : /
[ # 57 ] Comment from Farida [July 20, 2007, 10:02 am]
[ # 90 ] Comment from Charbax [August 13, 2007, 7:12 am]
[ # 760 ] Pingback from Блог unsimilar’а » Blog Archive » О геноциде префикса “category” [October 22, 2007, 11:34 pm]
[ # 2591 ] Comment from baa [March 31, 2008, 2:34 am]
[ # 3193 ] Comment from purose.cn [May 6, 2008, 7:44 pm]
[ # 3442 ] Comment from Safira [May 16, 2008, 12:34 pm]
hi Farida!
Thank you very much for support!
But i have a problem on my blog after removing “category” in my url’s.
The same problem like Charbax (above) told.
I am having problem when i am navigating to the category_name/page/2/ and im getting a 404 error
You can see it here: http://www.firanet.nl/kapsels-haarmode/page/2/
Do you have any idea how i can solve this problem?
[ # 3759 ] Comment from Brian [June 10, 2008, 9:37 pm]













[ # 28 ] Comment from Kris Rzepkowski [July 11, 2007, 7:14 pm]
Hi,
THANKS for this. I don’t really know php, so excuse me if te beow doesn’t make complete sense.
In order to make it work, I needed to do a couple of things…
1. I needed to copy and paste your code from my browser into notepad and change the curly quotes into standard text quotes. The way you have your font formatted doesn’t work when copying and pasting code
2. I found that the code errored out until I added a second quote in front of the second argument in the array, so I ended up with the following as the inserted line, and it worked:
$catlink = str_replace(’/category’, “”, $catlink);