Support » Fixing WordPress » is ‘ categoryname/’ possible?

  • In options/permalink WordPress states:
    If you like, you may enter a custom prefix for your category URIs here. For example, /taxonomy/categorias would make your category links like If you leave this blank the default will be used.
    However I want to use In other words, I want to replace the default prefix ‘category’ with no prefix at all.
    I think I would have to hack WordPress to do this, but I wouldn’t know where to start. Anybody?

Viewing 15 replies - 1 through 15 (of 15 total)
  • I think the default is just the category name.

    Well, as I understand it default is
    I would like to have:

    A server redirect looks like the only way. I may be wrong.

    The answers come quicker than this page loads 🙂 and now I somehow lost my cursor in this textfield in firefox…
    concerning redirect:
    would have to be an external redirect above the existing internal redirect, a bit ugly. Furthermore a link to would be in the html as because WordPress doesn’t ‘know’ about the external redirect.
    hmmm. There must be a php file in WordPress where this /category/ thing is stored…

    function get_category_link in the file template-functions-category.php
    Look at lines 30-31.

    thank you mr. Virus!
    removed “category/” on line 31 and changed category rewrite rule to
    RewriteRule ^([_0-9a-z-]+)/?$ /wordpress/index.php?category_name=$1 [QSA]
    This is just a simple beginning (have to do something about subcats) but what I’m looking for is a way to use wordpress with clients in a less weblog like way where category structure would represent the site structure.
    Thanks again. Sure tell me if you think I’m on the wrong track.

    I intend to use the solution above. My question, though, is what happens with subcategories, thomasmaas? A website I have depends heavily upon them.
    It would be best, in my case at least, if the default were no prefix at all. Or if a backslash meant no prefix…or something.


    by entering a ‘wrong’ categoryname this hack causes the following error:
    Database error: [You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 3]
    SELECT category_id, cat_name, category_nicename, category_description, category_parent FROM wp_categories, wp_post2cat WHERE wp_post2cat.category_id = cat_ID AND wp_post2cat.post_id =
    Warning: Invalid argument supplied for foreach() in /htdocs/wordpress/wp-includes/template-functions-category.php on line 90
    any idea

    had you tried this fix to remove the word ‘category’?

    from aleck:

    To remove the word “category” in category permalinks, you need to change the following line in wp-includes/classes.php:

    $this->category_structure = $this->front . 'category/';

    into this:

    $this->category_structure = $this->front;

    This is in get_category_permastruct() method. WP’s mod-rewrite rules already cover URL’s like this, so no problems there. I’m building the theme for my blog and this works great so far. I’ll report if I encounter problems with it. ” – from aleck

    Nothing like dredging up old posts nearly a year later.

    I’d like to note that doing this MAY break WP1.5 since the struture for Pages uses that format for permalinks (which is why ” WP’s mod-rewrite rules already cover URL’s like this”. Also, it makes it harder for the server to determine if you want to display the category by that name, a Page by that name, or to actualy go to a directory of that name.

    So, while it may very well work, it could cause problems down the road, so becareful.


    DOH! I completely didn’t even notice the date.

    My bad. sorry about that, TechGnome.


    Don’t sweat it…. happens a lot around here…. not the first, won’t be the last either.

    Heck, I did the same myself the other day…. although I had done it intentionaly. But at least now, it’s been freshened up with new info and people searching for the answer should be able to find it now.


    Interesting thread, I’m scared to try this now as I might break something!

    Can anyone please advise on how to fix the permalinks on my (very rough beta) site…. I have static pages to match each category of post… so for MP3s there is a static page called MP3s,

    I also have a post category called MP3s, so each post goes into this same directory, eg

    But now if you click the MP3 category link in the meta data, you are taken to because my permalinks are set /%category%/%year%/%postname%/

    (Sorry to bore ya by spelling this all out, but think it might help me get my head round all this!)

    Thanks for reading this far…. is there a safe way in to emit this extra ‘category’?

    Ah think I have a sneaky solution 🙂

    Set the category base to go up a directory, and then back to the main directory again…

    Category base: /../fresh

    Seems to work a treat! Nothing like answering your own posts as well…

    3stripe, you da man!!

    too simple to think of…heh

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘is ‘ categoryname/’ possible?’ is closed to new replies.