Is there any way (plugin or function), to include the sub-category and the category automatically in the permalink structure?

I want an URL structure like this:



set the permalink as


When you set a category parent of child, the permalink will be


I tried and worked fine!


  • 3
    Thanks for sharing this. It's working for me! But for this you need to assign only "sub-category" to the post. Means, I have a post under "parent category > sub-category1", so, I will assign "sub-category1" to the post and not the "parent category" and "sub-category1". – Anuja Deshpande Patil May 20 '13 at 9:15
  • Just to add clarity; only assign the child-category to include both parent and child in the URL, otherwise, if you pick both then it will assign it to parent only in the URL – WolfieZero Oct 1 '14 at 11:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.