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:

  1. http://www.mydomain.com = the homepage of the blog, bits and pieces from ALL categories
  2. http://www.mydomain.com/food = the food sub homepage, bits and pieces from all sub-categories under Food
  3. http://www.mydomain.com/fashion = the fashion sub homepage, bits and pieces from all sub-categories under Fashion
  4. http://www.mydomain.com/european = the european sub homepage, bits and pieces from all European sub-categories under both Food and Fashion
  5. http://www.mydomain.com/european/food = the european food sub homepage, bits and pieces from the Food>European sub category
  6. 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:

  1. http://www.mydomain.com/european/italian/food/25115886/how-to-bake-the-right-pizza

  2. 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.?

Read more here: How to achieve a clean custom permalink solution?


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , ,

Wordpress related questions and answers: