Create permalink with category as hostname? (4 posts)

  1. emonk
    Posted 8 years ago #

    Hiya. Long time lurker, first time n00b Steve here. I've got a simple question that will probably require a complex answer, so here goes.

    How do I create a permalink structure that like: '%category%.myblog.com/%postname%'?

    I am using WP 2.04 on dreamhost at http://quicksilverscreen.com/, so what I'm looking for is for my Linux posts to be located at http://linux.quicksilverscreen.com/, and my funny posts to be at http://funny.quicksilverscreen.com/. I'm stumped, so any help would be much appreciated.

    I've tried just sticking that into the permalink options, but it seems to just ignore everthing before '/%postname%'. Arggh. I want each category to have it's own hostname, why is this soo hard?

    I could write my own mod-rewrite script, and I've already set up the DNS wildcard, now if only I could get WP to spit out URL's in the expected format.

    My twelve readers are counting on me to bring them the latest useless news, and pointless trivia! Without your help almost a DOZEN faithful readers may have to live without my pointless, shortsighted ramblings!


  2. moshu
    Posted 8 years ago #

    That's not "hostname" - as you put it in the title: that's subdomain.
    WP's nice permalinks don't create and don't imitate subdomains. You have to live with that (as well as the 12 :)

  3. emonk
    Posted 8 years ago #

    @Moshu - You know, my mom once told me something similar about my goal to become the worlds fattest starving artist. I told her to scrump off, and I did it anyhow.

    Now I shall tell you the same thing. With god as my witness, I SHALL have subdomain based permalinks, even if it kills you*. :)

    * So long as it doesn't involve actual work.

  4. emonk
    Posted 8 years ago #

    Ok. I got it to mostly work now. I just inserted the following code in template-functions-links.php on line 80:

    $cats = get_the_category($post->ID);
    $category = $cats[1]->category_nicename;
    $home = "http://$category.quicksilverscreen.com";

    Notice that I used $cats[1], but thats because my first category $cats[0] is always 'All'. YMMV.

Topic Closed

This topic has been closed to new replies.

About this Topic