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 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

share|improve this question
    
Is "country" a "sub-tax" inside your (hopefully hierarchical) taxonomy "continent"? –  kaiser Dec 14 '11 at 10:36
    
Oh right, silly me. I didn't think to create just one continent taxonomy and have the countries as sub-taxonomies. But it still doesn't solve the issue with my urls displaying the actual continent and country terms, rather than the taxonomy names themselves. e.g. at the moment I suspect it will display mydomain.com/continent/country/beijing whereas I want it to display mydomain.com/asia/china/beijing –  remi90 Dec 14 '11 at 11:07
add comment

1 Answer

up vote 1 down vote accepted

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

share|improve this answer
    
Oh right, so do you mean create a custom post type called 'cities' for example, and then create countries page and continents page and set them as parents of that custom post type? –  remi90 Dec 14 '11 at 11:18
    
@remi90 Yes, exactly. You’ll need very similar meta data anyway: population size, geo coordinates, above mean sea level, spoken languages … it is much easier to implement this for one custom post type. –  toscho Dec 14 '11 at 11:42
    
But after a quick google search, it seems that setting a PAGE as the parent of a custom post-type is not very straight-forward, and Wordpress does not support it. Let me know if you have a way around this though? –  remi90 Dec 14 '11 at 11:46
    
You make the CPT hierarchical ('hierarchical' => TRUE), create a CPT page for the continent, a second for the country with the continent as parent, and a third for the city with the country as parent. –  toscho Dec 14 '11 at 12:25
    
Sorry to be pain. I understand what you are saying in your comment - that I should create a custom post type thats hierarchical and then create a page for each continent (asia, europe, africa), for each country (china, england, ghana) and make it's parent the continent, and then create a page for each city (beijing) and make the country the parent. But where exactly can I do that? I don't have the option to set page parents or anything within my custom post type admin area. I must be missing something obvious? –  remi90 Dec 14 '11 at 12:56
show 3 more comments

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.