Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I found out something weird today.

The current permalink is set to /%category%/%postname%/ but this happens (example):

I have a parent category Food and 4 subcategories Burger, Pancake, Waffles, and Pizza. As expected, the link should appear like this: foo.com/food/burger/post-name but it only works on 2 of my categories and looks like so:

foo.com/food/burger/post-name-1
foo.com/food/pancake/post-name-2
foo.com/food/post-name-3
foo.com/food/post-name-4

I'm refreshing the permalink settings but it doesn't seem to work.

I've even tried renaming Burger and Pancake to something else, both of them still look fine. But even if I rename Waffles and Pizza to Burger and Pancake, they still don't appear in the permalink.

Any quick solutions for this? Do I have to enter a custom taxonomy thingy?

share|improve this question
    
Is it possible that Waffles and Pizza(I've got to check your site out when it's done ;D ) don't have the food category set as the parent? –  Ben Sep 28 '12 at 17:24
    
All of them already have Food as the parent. :-/ –  ton Sep 28 '12 at 17:34
    
To further narrow down the possibilites: what is the url if you make a new "test" category as a child of "food", then visit a post you put into the test category? –  Ben Sep 28 '12 at 18:20
    
Food still doesn't appear. I think a solution for this is making sure to create all child categories first before adding and setting the parent category. That's based on my feedback on the answer below. Thanks though. :D –  ton Sep 29 '12 at 18:43

2 Answers 2

up vote 0 down vote accepted

When a post belongs to more than one category, regardless of their parent/child structure, WordPress will use the category with the lowest ID in the permalink. If that lower ID belongs to a child category, you'll see the parent/child structure in the permalink.

If you always want parent/child category appearing in the permalink, a simple solution would be to only assign the child category to the post.

share|improve this answer
    
You know what, you gave me the idea on a (dirty, but working) solution I've been longing for. I modified the database table wp_terms and just increased the ID of my parent category to a very high 99. Since the IDs of the child categories are now way lower than the parent's, I think they both appear now on the permalink of all posts. Thanks a lot!!! I'm not sure if it will be helpful to others, but I'll be accepting this anyway. –  ton Sep 29 '12 at 18:39

The trick is to first add all your sub categories, then add your parent category. Then you go through the child ones and assign them to the parent!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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