Forums

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

  1. erick_paper
    Member
    Posted 9 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!

  2. t3ch33
    Member
    Posted 9 months ago #

    use a rewrite

  3. erick_paper
    Member
    Posted 9 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".

  4. Otto42
    Moderator
    Posted 9 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.

  5. erick_paper
    Member
    Posted 9 months ago #

    Thanks for a very informative post!

    I found the "category base" works for me.

  6. KingRosales
    Member
    Posted 9 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.

  7. wdm
    Member
    Posted 4 months ago #

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

  8. wdm
    Member
    Posted 4 months ago #

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

  9. JoshuaGoodwin
    Member
    Posted 4 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