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.

Let's say I've created two custom post types, one called post_type_author and another called post_type_book. In each of these two custom post types, I've created a non-hierarchical taxonomy for tags.

What is the best way to associate these two custom post type's taxonomies?

Also, if I wanted to link these two along with the default "post" post type, how would that be done?

What I want is to use the same non-hierarchical taxonomy "tags" for each of the three post types, so that a tag permalink called "Chicago", for example, will pull a post called "Saul Bellow" from the "post_type_author" custom post type.

It should also pull a post called "Great Chicago Landmarks" from the "post_type_book" custom post type tagged "Chicago" AND another post from the default "post" post type that was also tagged "Chicago".

Do I create two additional taxonomies and link them to the "post" post type taxonomy? Or is there a better way?

I hope this makes sense and thanks very much.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Create one taxonomy and share it across all post types. You won't be able to have the same slug across multiple taxonomies anyway, they have to be unique due to the way they're stored in the database.

You can use the built in tags taxonomy with your custom post type by setting

'taxonomy' => array('post_tag')

when you register your custom post type, or you can add a custom taxonomy to regular posts (as well as your custom types) when you register your taxonomy by passing an array for $object_type:

array('post', 'post_type_author', 'post_type_book')
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.