WordPress.org

Ready to get started?Download WordPress

Forums

is 'www.mydomain.com/ categoryname/' possible? (16 posts)

  1. thomasmaas
    Member
    Posted 10 years ago #

    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 http://example.org/taxonomy/categorias/general/. If you leave this blank the default will be used.
    However I want to use http://www.mydomain.com/categoryname/. 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?
    Thanks.

  2. Nick Momrik
    Member
    Posted 10 years ago #

    I think the default is just the category name.

  3. thomasmaas
    Member
    Posted 10 years ago #

    Well, as I understand it default is http://www.mydomain.com/category/categoryname/.
    I would like to have:
    http://www.mydomain.com/categoryname/.

  4. Root
    Member
    Posted 10 years ago #

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

  5. thomasmaas
    Member
    Posted 10 years ago #

    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 http://www.mydomain.com/categoryname/. would be in the html as http://www.mydomain.com/category/categoryname/ because WordPress doesn't 'know' about the external redirect.
    hmmm. There must be a php file in WordPress where this /category/ thing is stored...

  6. Nick Momrik
    Member
    Posted 10 years ago #

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

  7. thomasmaas
    Member
    Posted 10 years ago #

    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.

  8. jareha
    Member
    Posted 10 years ago #

    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.

  9. Anonymous
    Unregistered
    Posted 10 years ago #

    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
    thanks

  10. nearlythere
    Member
    Posted 9 years ago #

    had you tried this fix to remove the word 'category'?

    from aleck: http://wordpress.org/support/topic.php?id=18304#post-141363

    "
    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

  11. TechGnome
    Moderator
    Posted 9 years ago #

    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.

    Tg

  12. nearlythere
    Member
    Posted 9 years ago #

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

    My bad. sorry about that, TechGnome.

    -h

  13. TechGnome
    Moderator
    Posted 9 years ago #

    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.

    Tg

  14. 3stripe
    Member
    Posted 9 years ago #

    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, http://www.clubtng.com/fresh/mp3s/

    I also have a post category called MP3s, so each post goes into this same directory, eg http://www.clubtng.com/fresh/mp3s/2005/electrobreaks-mix/

    But now if you click the MP3 category link in the meta data, you are taken to http://www.clubtng.com/fresh/category/mp3s/ 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 1.5.1.2 to emit this extra 'category'?

  15. 3stripe
    Member
    Posted 9 years ago #

    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...

  16. pedah
    Member
    Posted 8 years ago #

    3stripe, you da man!!

    too simple to think of...heh

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.