Including two taxonomies in a permalink structure

I am trying to get my head around the permalink structures on WordPress sites, and I’m a bit stuck with what I’m trying to achieve:

My current permalink structure: /%category%/%postname%/

I have a custom-post type called ‘city’, and I want to create a structure like below:

mydomain.com/asia/china/beijing

So just to explain this structure:

asia – This is a term under a taxonomy called ‘continent’

china – This is a term under another taxonomy called ‘country’

beijing – This is the actual custom-post type post with title ‘Beijing’

So I basically have two taxonomies (continent and country) linking to my ‘city’ post type. So the way I see it, I need a structure like this:

mydomain.com/(taxonomy-continent)/(taxonomy-country)/(custom-post)

But I cannot seem to figure out how to achieve this with the permalink structure.

Any help would be greatly appreciated!

Thanks

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You don’t need these two taxonomies. Just make your custom post type for places hierarchical and set countries and continents as parents. WordPress will build your permalinks then exactly as you want it.

After you’ve created the first post you get a selector for page parents from which you can choose:

enter image description here


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x