WordPress.org

Ready to get started?Download WordPress

Forums

Rename "category" slug in URL (22 posts)

  1. thelaw
    Member
    Posted 5 years ago #

    I was wondering if anyone successfully renamed the "category" slug that is in every WordPress install. While I was able to remove the word from most items, it must appear when viewing subcategories or else it would result in an error. I've accepted that this is unfortunately a part of WordPress for the moment even though it should be priority for the WP team to fix in 2.8! ;)

    As a workaround, I figured I could rename the word category to autos, e.g.

    http://www.mysite.com/category/cars/audi/ to

    http://www.mysite.com/autos/cars/audi/

    At least this would be better for SEO - anyone do this before? Just want to make sure it works. Trying to remove category slug never worked no matter which solution I tried.

  2. esmi
    Forum Moderator
    Posted 5 years ago #

    Seems to me that this would be better addressed by setting up custom permalinks via Admin/Settings/Permalinks

  3. thelaw
    Member
    Posted 5 years ago #

    Esmi - thanks but that isn't the case. The problem is as follows. Put in your permalinks: /%postname%/

    You think that will not output the "category" right? Wrong. It doesn't put out a category if you're looking at a directory or post but if you're looking at a subdirectory, WordPress inserts the word "category" into your URL. This is a known problem and there is no solution I've found that works reliably.

    The URL should appear as:

    http://www.yoursite.com/firstcat/secondcat

    but wordpress outputs it as:

    http://www.yoursite.com/category/firstcat/secondcat

    This is INCREDIBLY annoying.

  4. iridiax
    Member
    Posted 5 years ago #

    Did you change the Category base? Just use a web-safe word for this (no percents or slashes).

    http://codex.wordpress.org/Permalinks_Options_SubPanel

  5. thelaw
    Member
    Posted 5 years ago #

    Thanks but this is not what I'm talking about. If you put in a category base, you'll get the category link every time. You'll get:

    yoursite.com/categorybase/firstcat/

    I don't want any category base at all. The problem is that WordPress will put one in there even if you don't have anything entered and you're just looking for mysite/com/postname/

    This is a problem that has been attempted to be handled for years if you search for it, e.g. remove category slug, etc. I'm trying to remove the default entry of the word "category" from the URL when WordPress decides to enter it, such as when you are browsing main and subcategories. I think it may be in the cateogry-template.php in the wp-includes folder and was wondering if anyone did this before.

  6. thelaw
    Member
    Posted 5 years ago #

    yeesh... has NOBODY done this before? OK... I'm going to have to hack this myself and see all the other WP blogs out there still displaying "categories" in their extended URLs!!!

  7. @mercime
    Volunteer Moderator
    Posted 5 years ago #

  8. thelaw
    Member
    Posted 5 years ago #

    Wow - thanks - this version worked for me. Prior versions were not successful.

  9. thelaw
    Member
    Posted 5 years ago #

    Bummer - I spoke to soon. More errors just to solve this stupid issue. It occurs on my main index page for all my categories and makes no sense as to why it occurs.

    Warning: preg_match() [function.preg-match]: Compilation failed: unrecognized character after (? or (?- at offset 147 in /home/mysite/public_html/wp-content/plugins/redirection/models/redirect.php on line 318

    I think I'm just better off changing the name of "category" to the slug that I want to use instead of "cagegory" like "cars"

  10. @mercime
    Volunteer Moderator
    Posted 5 years ago #

    Not to belabor this point but with the decategorizer installed, you would need to input the NEW URL's (because no more /category/ in URL's) which you redirected to within your post.

  11. thelaw
    Member
    Posted 5 years ago #

    Not sure I understand - the decategorizer worked for most pages, just not all. I found another plugin I'm testing that is actually doing the job quite well right now... we'll see. The plugin should be standard wordpress...

  12. eworque
    Member
    Posted 5 years ago #

    try this:

    /%category%/%postname%/

    It works fine.

  13. thelaw
    Member
    Posted 5 years ago #

    eworque - thanks for the post but putting in category into the permalink means you'll then have the category in every permalink you generate.

    Unfortunately the new plugin worked for a bit and now spits out 404 errors. The problem is that if you just put in /%postname%/ , WordPress will put in the word "category" when you get past one level of categorization. Nothing anyone has suggested has worked reliably, not htaccess modifications, not the redirection plugin -- NOTHING. I've wasted far too much time on this unfortunately.

    The simple solution I want to find is how to change that word "category" to something else only in the instance when WordPress makes it happen, when viewing a category + subcategory in the URL structure. Getting rid of the slug makes WordPress unreliable.

    Many thanks to everyone trying to help out. This has plagued much of the community unfortunately.

  14. thelaw
    Member
    Posted 5 years ago #

    Nope... nothing works. WordPress must have its "category" slug somewhere. With every plugin, htaccess hack, it fixes one item and breaks the other. If you fix the category, it breaks subcategories and vice versa. I'm just going to see if I can change the slug "category" to something useful like "cars" and bedone with this mess.

  15. thelaw
    Member
    Posted 5 years ago #

    Bleah... nobody has done this? OK... I'll take a stab at it and see what I can do at hacking a good solution.

  16. tr33m4n
    Member
    Posted 5 years ago #

    Hey,

    Not sure whether you've tried this (too tired to read entire post) http://www.keyframe5.com/how-to-remove-category-slug-from-wordpress-url/ im gonna give it a try now, as Im in the same boat as you :)

    Dan

  17. tr33m4n
    Member
    Posted 5 years ago #

    I tried this and it worked perfectly :) Hope you have similar success

    Cheers
    Dan

  18. alainS
    Member
    Posted 5 years ago #

    I've solved this without a plugin.

    Just type ./ for category base in the admin panel and update.
    It's simple and it works. I'm using ith with this structure: /%category%/%postname%.php

  19. thelaw
    Member
    Posted 4 years ago #

    The problem is that (a) you will then have the category or categories in the URL of the article, and (b) you have to have a .php at the end of the article, which isn't optimal, especially if you ever deal with multiple pages.

  20. phr34k
    Member
    Posted 4 years ago #

    I'm using the same permalink structure as you (/%postname%/) and I use WP No Category Base with no problems at all.

    HTH

  21. eclecticcook
    Member
    Posted 4 years ago #

    If you want to rename the category base to something else, in the admin panel, go to Settings – Permalinks. Under the “Optional” section, look for “Category base”. Write in whatever word you want to replace the word “category” in your url with whatever word you choose. Change http://www.mysite.com/category/post name/ to http://www.mysite.com/your word/post name/

    If you want to remove the category base completely, use the “WP No Category Base” plugin.

  22. Shane G.
    Member
    Posted 4 years ago #

    Hi,

    Add this code in htaccess of your blog and have a check:

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

    Thanks,

    Shane G.

Topic Closed

This topic has been closed to new replies.

About this Topic