Hacking Category Permalinks…
-
Alright, I set up my Categories to be in different directories, with different indexes.
What I needed was, for every link generated by the_category to link to the category directory I created. To make things simple, I named each category directory as WordPress would generate it (ex: “My Awesome Category” = “my-awesome-category”).
(Keep reading to the bottom, I have a question at the end of this) 🙂
So about a month ago I can up with a solution for this…
Instead of a mod-rewrite, I dived into the code.
It’s rather simple actually:
Open up: templates-functions-category.php
Around line 30, change:
$link = $file.$querystring_start.'cat'.$querystring_equal.$cat_ID;$link = ‘http://www.site.com/wpblog/’ . $category_nicename . ‘/’;
to:
It will output all of your Category permalinks from:
http://www.site.com/wpblog/index.php?cat=5
to:
http://www.site.com/wpblog/whatever-the-category-name-is/
Now here’s my problem… that works fine and dandy for categories, but it doesn’t work for subcategories. Well, it works, but it doesn’t include the parent category directory infront of the subcategory directory name 🙁
The above code needs to somehow work where it creates links as:
http://www.site.com/wpblog/the-category-name/
and with subcategories:
http://www.site.com/wpblog/parent-category/subcategory/
Any help appreciated 🙂
The topic ‘Hacking Category Permalinks…’ is closed to new replies.