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.

My head hurts...

Here is what I have:

Custom post type: Our People, slug => our-people
Taxonomy: Job Title, slug => job-title

I have an archive page for the Our People CPT at domain.com/our-people.

I can easily have archive pages for the Job Title taxonomy terms at domain.com/job-title/{term}

But I would like to have archive pages for the Job Title taxonomy terms under the our-people slug.

Example:
domain.com/our-people/managers
domain.com/our-people/crew

Where managers and crew are terms of the taxonomy Job Title, which is attached the the CPT Our People.

Is there a way to do this? Setting the taxonomy and the CPT to the same slug obviously didn't work.

Thank you.

share|improve this question
    
I guess I need to read up on WP_Rewrite, but I still don't know how/if it is possible for two things (CPT and taxonomy) to share the same slug. –  Gabriel Jun 17 '12 at 14:46
add comment

3 Answers 3

up vote 3 down vote accepted

You have two avenues:

  • Hardcode rewrite rules for those specific URLs
  • Abandon your quest and design a new URL structure

What your asking for cannot be automated efficiently because it would mean 2 rewrite rules that are the same, but are mapped on to different things. The result being that either the post type slug would take precedence, or the job would take precedence, but only one.

E.g. say we had the url our-people/example, is referring to the people 'example' or the job 'example'? Either WordPress will find the person named example, and 404 if it can't ( despite there being one under job. Or it will do it the other way around

My Recommendation

Change your URL structure to be less confusing and make more sense by nesting them:

example.com/our-people/johnsmith
example.com/our-people/jobs/managers

do this by setting the rewrite value when you register your jobs taxonomy ( it's okay to use a / )

share|improve this answer
add comment

WordPress doesn't understand your URL, because there is no rewrite rule for it. You have to add custom rewrite rule in case you want to make it working. Read The Rewrite API: The Basics article. There is all what you need.

share|improve this answer
add comment

Another option would be to use the Custom Post Type Permalinks plugin -- it does this automatically as part of its feature set (it's a simple checkbox on the Permalinks page).

share|improve this answer
add comment

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.