Delete The Word Category In WordPress Category Url With Plugins And PHP Tag

by Abi on February 1, 2009

By default WordPress set category url with the word “category” or prefix within it. But some people regard as ugly url and not too SEO url. Actually we can remove the word, and there are 2 ways to remove the word “category” in category url, one with plugin or add php tag in category template php. And in this post SEO Blog will explain on how to remove word “Category”.

I give a picture of what I am talking now, your category url by default is like this:

http://blogname.com/category/seo

And we want to remove the word “Category” into this url:

http://blogname.com/seo

*. SEO is the name of the category.

1. Using Plugins, there are 2 plugins I know that could remove the “category/” text from WordPress URL string

A. Using Top Level Categories

You can download the Top level Categories here.

B. Using Category Base Removal Plugin

You can download the Top level Categories here.

2. Using PHP tag. I think you better use plugins, because it’s a lot easier. But in regard of sharing knowledge I post this way too.

1. Login to your WordPress via FTP, and go to category-template.php.
2. And find this:

$catlink = str_replace('%category%', $category_nicename, $catlink);

3. And put the following tag right beneath the above tag:

$catlink = str_replace('category/', '', $catlink);

The tag within your category-template.php should look like the following image:

category url in category-template.php

Click the image to have a bigger view.

And the last thing you need to do is change your permalink into this permalink structure (go to setting – > permalink):

%category%/%postname%

.

Done!

There is also a problem if your current permalink structure is none as the above permalink. To resolve this you need a Permalink migration plugins. Go to this post because I’ve listed number of migration permalink plugins. Just wait:D. See you in the next post.

Related posts:

  1. Permalink Migration Plugins To Permenantly Moved Ugly Permalinks Into Pretty Url
  2. SEO Your WordPress Description And Keyword Without Plugins
  3. How To Exclude WordPress Category
  4. SEO Your WordPress Category With Description
  5. Magasin Dos WordPress Theme Free

{ 11 comments }

Alec February 18, 2009 at 5:35 am

Thanks a lot Abi. We were having a lot of trouble with removing category in Wordpress 2.7. Your hack is a good start for now. Would love to see those plugins updated though.

rudy February 18, 2009 at 4:59 pm

Saya termasuk yg beruntung Mas. Nyasar ke salah satu blogs yang ngasih tau hal ini dari awal. Jadi settingan permalink nya udah seperti yg Mas Abi anjurkan. :D
Sekarang hal ini dibookmark ama saya.

Hanna February 28, 2009 at 8:04 pm

Worked like a charm! Thanks for posting.

Abi March 1, 2009 at 4:16 am

@Alecm  you welcome buddy!

@Rudy,  sip mas Rudy

@Hanna, you welcome friend

Pablo Almeida April 16, 2009 at 1:42 am

It works only first-level categories. And has a bug: doesn’t works with subcategories!  :(

Abi April 16, 2009 at 6:07 am

Yes this technique works for parent category only  – and if your blog owns child category – it will go to 404 page.

Funny SMS May 29, 2009 at 5:27 pm

Hi,
Previously I was using a plugin called “Top Level Cats” for the same purpose. When I tried to upgrade WP to the latest version, that plugin started giving problem.

Thanks to your tip, I have now upgraded to WP 2.7.1 and everything is working perfect. Thank you so much.

param July 15, 2009 at 2:39 pm

works like charms… thank you soo much

love sms August 26, 2009 at 2:23 am

work only in parent category… what to do next?

Love SMS October 4, 2009 at 12:02 pm

nice post thank you so much for sharing

html tips October 9, 2009 at 1:23 am

Thanks for the links and the explanation, I will use this on my website!

Comments on this entry are closed.

Previous post:

Next post: