I am working on the design of a blog with the below(just a sample) category hierarchy.
PARENT
|
|------------------------------------------------|
Food Fashion
| |
|---------------------| |---------------------|
European Asian European Asian
| | | |
|---------| |-----------| |--------| |--------|
Italian French Chinese Japanese Italian French Chinese Japanese
The client will blog on Food and Fashion with posts categorised by country. Meaning that a post about Italian Pizza will go under PARENT > Food > European > Italian
My problem is with permalinks as the client wants the below structure for categories:
- http://www.mydomain.com = the homepage of the blog, bits and pieces from ALL categories
- http://www.mydomain.com/food = the food sub homepage, bits and pieces from all sub-categories under Food
- http://www.mydomain.com/fashion = the fashion sub homepage, bits and pieces from all sub-categories under Fashion
- http://www.mydomain.com/european = the european sub homepage, bits and pieces from all European sub-categories under both Food and Fashion
- http://www.mydomain.com/european/food = the european food sub homepage, bits and pieces from the Food>European sub category
- http://www.mydomain.com/european/italian/food = the italian food sub homepage, bits and pieces from the Food>European>Italian sub category
etc.
And this structure for posts:
http://www.mydomain.com/european/italian/food/25115886/how-to-bake-the-right-pizza
http://www.mydomain.com/european/italian/fashion/25175191/milan-fashion-show-in-june
My main problem with Wordpress' native way of managing permalinks is course the category base /category/ added by Wordpress. Also a headache is the fact that /european/italian/food is NOT in the order the category is saved, which is /food/european/italian.
I therefore tried testing around with the below code in my template's functions.php file:
add_filter( 'category_link', 'bloglinks', 10, 2 );
function bloglinks( $catlink, $category_id )
{
}
I was thinking of carrying out a check against the category IDs(which will never change) inside the function and build the permalink I want.
But is that the right place to do all the coding? Will I break anything, like plugins, etc.?