Forums

How to remove "/category" from the category URL? (9 posts)

erick_paper
Member
Posted 8 months ago #

Hi. In my theme, the category links show up as:

http://domain.com/wp/category/mycat

For backward compatibility of URLs, I would like to remove the bold word in that URL ("/category") because wordpress in fact works if I remove that. Just the name of the category ("mycat" in my example) is fine to bring up the category archive without any problem.

Thanks for any tips!

t3ch33
Member
Posted 8 months ago #

use a rewrite

erick_paper
Member
Posted 8 months ago #

I think it's not an issue of doing a rewrite, because the theme itself writes the URLs. I want to change how the category URL is linked from within the theme while calling wp_list_categories.

So the "/category" is autmatically added by WP!

I checked the options for this function:
http://codex.wordpress.org/Template_Tags/wp_list_categories

But there seems to be none that allows me to personalize the word used for "category".

Otto42
Moderator
Posted 8 months ago #

You can change the word to anything you like on the Options->Permalink page, but you cannot remove it. The identifier is needed to signal that you are asking for a category.

As for why it works without it, let me guess: Your Custom Permalink string starts with /%category% , right? If it didn't, then leaving it out would not work.

Removing it entirely would require a large rewrite of the internal rewrite and query system. Using category in the custom permalinks is a bit of a hack anyway, since there is not a one-to-one correspondence between categories and posts; posts can have more than one category.

erick_paper
Member
Posted 8 months ago #

Thanks for a very informative post!

I found the "category base" works for me.

KingRosales
Member
Posted 7 months ago #

I have a site that automatically lists the categories prefixed with "domain-name/category/directory-name".

If you create a navigation menu and simply hard-code "domain-name/directory-name", I've discovered that it works just the same; The hard-coded urls also get indexed like every other page on your website or blog.

- I've used this technique on my sites that I want to ensure the url and directory can easily be memorized.

However, in most cases, if you dont have a SEO keyword in your domain name, I recommend using the "category" structure and replace that with an industry keyword.

wdm
Member
Posted 2 months ago #

Using "/." (without quotes) as the category base should work

wdm
Member
Posted 2 months ago #

Hmm... it did work, but not anymore.
Seems not to work all the time, anyone know why?

JoshuaGoodwin
Member
Posted 2 months ago #

Use the top level categories plugin, if you want to remove the prefix altogether.

Reply

You must log in to post.

About this Topic

RSS feed for this topic Started 8 months ago by erick_paper Latest reply from JoshuaGoodwin WordPress version: 2.3.3 This topic is not resolved


You are viewing a mobilized version of this site...
View original page here

Mobilized by Mowser Mowser