WordPress.org

Ready to get started?Download WordPress

Forums

Hacking Category Permalinks... (5 posts)

  1. flyingrabbit
    Member
    Posted 9 years ago #

    "Alright, I set up my Categories to be in different directories, with different indexes."
    How did you do this? I've been trying to find a tutorial or instrructions that explain how to pull this off and have had no luck.
    Does the code distinguish between categories and subcategories? You could change your hack to a conditional statment - i.e. if this is a subcategory, set $categoryparent to the nincename of the category's parent, and then do this: $link = 'http://www.site.com/wpblog/' . $categoryparent . $category_nicename . '/';, otherwise have it do your original hack.
    If you can't dymanically figure out whether or not a given caetegory is a subcategory, just hard-code categories who are subcategories into an array:
    $subcats = array(0 => 'category-x', 1 => 'category-x', 2 => 'category-x', 3 => 'category-x');
    where 'category-x' is whatever-the-category-name-is
    then do a conditional to test and see if the category is one of those:
    if (in_array(category_nicename, $subcats)){
    $link = 'http://www.site.com/wpblog/' . $categoryparent . $category_nicename . '/';
    else:
    $link = 'http://www.site.com/wpblog/' . $category_nicename . '/';
    endif;
    }
    of course, you might do best to have multiple arrays, one for each parent category, continaing its subcategories, but then you'd have to test each array seperately. But this would give you the parent category name to drop into $categoryparent.
    HTH.

  2. flyingrabbit
    Member
    Posted 9 years ago #

    There is a category_parent object and a get_category_parents method, but I'm not sure how they're used. But you should be able to test to see if a given category has a parent using one or both.

  3. Kelso
    Member
    Posted 9 years ago #

    Hi, thanks for the reply! :)
    I'll check up on your code later tonight and get back to you...
    To set up my categories to be on seperate indexes in seperate directories, just duplicate the index.php, put it in a different directory (and name it to your category name - spaces are "-"), and make sure the header tags it calls for are pointing to the right path. Then you have to add:
    `$cat = 1;
    to the top of your page after the opening "<?php" tag. The number in the number of the category you want showing on that page.
    Let me know it's still unclear... I'll get back to you in the morning... off to work ;)

  4. Kelso
    Member
    Posted 9 years ago #

    Hmmm, it doesn't seem to work :/

  5. Anonymous
    Unregistered
    Posted 9 years ago #

    bump :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.