How to remove category word from your WordPress url

  • Share
  • Share

WordPress Tips: How to remove category word from your WordPress url

Ever wanted to be able to finally remove the useless /category/ from your WordPress categories permalinks?

There are various options to remove “Category” Keyword from your WordPress URL’s.

1) .HTACCESS Hack

By default, WordPress category permalinks are displayed that way:

http://www.xyz.com/blog/category/wordpress

As you can see, the category in the url is pretty useless. Here’s how to remove it:

First backup your .htaccess file. Then, open it and append the following line:

RewriteRule ^category/(.+)$ http://www.xyz.com/$1 [R=301,L]

Once saved, your categories pages will be displayed like this:

http://www.xyz/blog/wordpress

2) WordPress Plugin – WP No Category Base

Category word can be easily removed by using WordPress plugin: WP No Category Base
You can download the plugin or directly install in your wordpress from here: http://wordpress.org/extend/plugins/wp-no-category-base/

As the name suggests this plugin will completely remove the mandatory ‘Category Base’ from your category permalinks ( e.g. myblog.com/category/my-category/ to myblog.com/my-category/ ).

Wordpress Customization

Wordpress Customization

The plugin requires no setup or modifying core wordpress files and will not break any links. It will also take care of redirecting your old category links to the new ones.
Features
1. Better and logical permalinks like myblog.com/my-category/ and myblog.com/my-category/my-post/.
2. Simple plugin – barely adds any overhead.
3. Works out of the box – no setup needed.
4. No need to modify wordpress files.
5. Doesn’t require other plugins to work.
6. Compatible with sitemap plugins.
7. Works with multiple sub-categories.
8. Redirects old category permalinks to the new ones (301 redirect, good for SEO).

3) Changing in Category-template.php File

When you create a category in wordpress “Technology” for examples sake with SEO URL re-writing enabled and then browse to that category on your wordpress install the URL structure will look like below.

http://yoursite.com/category/technology/

You will notice the word /category within the URL structure, what this wordpress hack achieves is the removal of the /category word from all URLS. After implementation this then means that the URL structure for categories would now look like below.

http://yoursite.com/technology/

Much cleaner right and it also moves url keywords further to the left.
How To Remove Category From WordPress URL

Open the file /wp-includes/category-template.php in a text editor, we would recommend using PSPad which is a free code editor.

Around line 42 of /wp-includes/category-template.php

FIND
$catlink = str_replace(‘%category%’, $category_nicename, $catlink);

BELOW ADD
$catlink = str_replace(‘category/’, ”, $catlink);

The code within the category-template.php should now look like the image below, the grayed out areas are the code you should have changed with line 43 being the code you added.

Save the /wp-includes/category-template.php file and upload it to your wordpress site.

Note: The following step is very important or your site will receive 404 errors for categories.

You need to tweak your sites permalink structure from the admin panel, this is done because all posts must have /%category%/ somewhere within the permalink structure. It’s also claimed to be a little better for seo as your urls will now contain more keywords further to the left of the url. This next step is done completely with the admin panel so no more file edits are required.

Goto your wordpress Administration page then Settings / Permalinks. You should be presented with a page like below.

Custom URL Code Snippet

Copy and paste the code below to your custom structure text field and click save.
/%category%/%postname%-%day%%monthnum%%year%/escort london girl

Related posts:

  1. Top 10 SEO Tips for Ecommerce Websites

2 Responses to “How to remove category word from your WordPress url”

  1. federal student loan says:

    nice post. thanks.

  2. bet365 says:

    hi I was fortunate to discover your topic on WordPress “Category word” removal in bing
    your topic is excellent I obtain much in your subject really thanks very much btw the theme of you site is really wonderful where can find it

Leave a Reply

© 2010 - 2011 Deepak Bisht. All rights reserved.
Other Websites- Uttarakhand : India Travel Deals