1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Wordpress Permalink Category Question

Discussion in 'WordPress' started by Bangkok Baby, Jan 21, 2007.

  1. #1
    I am using wordpress permalink structure in the following manner.

    /%category%/%postname%/

    So each of my posts appear under the respective category. (Eg: http://www.bangkokbaby.com/bangkok-city/human-imagery-museum-thailand )

    But when it comes to the category itself, it showing an additional folder name "category" before the name of the category. (Eg: http://www.bangkokbaby.com/category/bangkok-city/ )

    Is there any way I can get rid of the folder category and place the category name directly under doamin root.

    ie, instead of,
    bangkokbaby.com/category/bangkok-city/ , I need
    bangkokbaby.com/bangkok-city/

    Any plug-ins? Or should I use different tag for permalinks?

    PS: I tried to search on this board for an answer. But couldn't find. If a similar thread is already in BB, someone please tell me about that thread.
     
    Bangkok Baby, Jan 21, 2007 IP
  2. maiahost

    maiahost Guest

    Messages:
    664
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This is done so that no category has the same name as a blog post. Perhaps you can change the permalink code and get the results ? You should also look at the .htaccess file.
     
    maiahost, Jan 21, 2007 IP
  3. Bangkok Baby

    Bangkok Baby Peon

    Messages:
    322
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the reply.
    But I couldn't find an answer for using differnt permalink code.

    Infact if I check my categories without the category directory structure, that still shows me the content in real category. But by default there are no links pointing to this page.

    Ie, bangkokbaby.com/category/bangkok-city/ and
    bangkokbaby.com/bangkok-city/
    Both dispaly the same content. But the default is the first one and hence there won't be any links pointing to the second one unless I place some links to those pages manually.
     
    Bangkok Baby, Jan 21, 2007 IP
  4. maiahost

    maiahost Guest

    Messages:
    664
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #4
    OK you can change the linking structure, that I am sure about. Let me do a bit of code digging and I will tell you how to do it.
    I think I found some resources on this :
    http://jclark.org/weblog/2006/08/21/the-permalink-problem/
    You can read the whole thing but the solution is near the end ...
     
    maiahost, Jan 21, 2007 IP
  5. Bangkok Baby

    Bangkok Baby Peon

    Messages:
    322
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for that maiahost.

    I am not really a techo person. Not sure where exactly I should place that hack.
     
    Bangkok Baby, Jan 22, 2007 IP
  6. dcristo

    dcristo Illustrious Member

    Messages:
    19,776
    Likes Received:
    1,199
    Best Answers:
    7
    Trophy Points:
    470
    Articles:
    7
    #6
    If I understand you correctly, use /%postname%/ for the permalink structure instead.
     
    dcristo, Jan 22, 2007 IP
  7. Bangkok Baby

    Bangkok Baby Peon

    Messages:
    322
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #7

    Thanks for the reply. I am afarid I didn't convey the message properly.


    If I put the tag /%postname%/ , all my posts will appear directly under the root of the domian. I don't want that. I want all the posts to appear under respective category.
    ie, mysportsdomain.com/basketball/NBA-players, where basketball is the category and NBA-players is the post name. So far it is fine.

    But if I look for category it shows as, mysportsdomain.com/category/basketball/ where as I need it to be,
    mysportsdomain.com/basketball/

    Hope I explained it better this time. :)
     
    Bangkok Baby, Jan 24, 2007 IP
  8. Austars

    Austars Active Member

    Messages:
    1,437
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    95
    #8
    So you have the post permalinks working, but now you need the category permalinks to work correctly?
     
    Austars, Jan 24, 2007 IP
  9. Bangkok Baby

    Bangkok Baby Peon

    Messages:
    322
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #9

    It is working. But I want the category name to appear directly under the root of the domain when I am browsing the particular category archive.

    Maiahost understood my question properly. But unfortunately I am not able to follow his solution. :eek:
     
    Bangkok Baby, Jan 24, 2007 IP
  10. autorave

    autorave Peon

    Messages:
    995
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    0
    #10
    I found a blog with an explanation on how to do this when surfing on the same problem you have .. I'll try to find it and will post the URL if I do ..
     
    autorave, Jan 25, 2007 IP
  11. maiahost

    maiahost Guest

    Messages:
    664
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #11
    OK let me explain : this filter or 'hack' should be placed where you list your categories (sidebar.php most of the time but depends on the theme) at the very beginning of the file
    
    <?php
    function fix_category_links($content) {
        $content = str_replace('/category/', '/', $content);
        return $content;
    }
    add_filter('list_cats', 'fix_category_links');
    ?>
    
    Code (markup):
    Since I haven't written it and I will be able to test it tomorrow (too much work right now) make sure you copy the file first so nothing gets broken.
    Good Luck :)
     
    maiahost, Jan 25, 2007 IP
    Bangkok Baby likes this.
  12. Bangkok Baby

    Bangkok Baby Peon

    Messages:
    322
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Maiahost,

    PERFECT!
    Thanks a lot for your help. I just added a reputation to your credit. :)
     
    Bangkok Baby, Jan 25, 2007 IP