user3837342
user3837342

Reputation:

Making Category/Subcategory permalink for Subcategory archive page

For some reason when you create a subcategory in WP, the permalink to that page does not include it's parent in the url.

For example if you have a category structure like this animals < lizards, the only way you can see the lizards category page is by visiting www.example.com/lizards/. www.example.com/animals/lizards returns 404 but a post assigned to the lizards category still has the permalink as this www.example.com/animals/lizards/beardeddragon, assuming the permalink structure is set to /%category%/%postname%/

This seems to be a common problem as I've browsed the internet to find an answer but none worked for me.

Any ideas how I can fix this?

Upvotes: 1

Views: 2469

Answers (2)

ecairol
ecairol

Reputation: 6573

  • On your Permalinks use /%category%/%postname%/
  • On your Posts, when selecting two categories, WordPress will ask "Select the primary category". Choose the child category as the primary.

That will start showing both in the URL structure.

Upvotes: 2

user3837342
user3837342

Reputation:

I fixed it by following the first add_action solution here: https://wordpress.stackexchange.com/questions/58471/including-category-base-in-a-post-permalink-results-in-404

And then setting the custom structure to /%category%/%category%/%postname%/.

Upvotes: 0

Related Questions