0

This question already has an answer here:

I intend to set up the following:

  • CPT: job, team-member

They share

  • taxonomy: location

When I register location, I do this:

$args = array(
   ....
   'hierarchical'  => false,
   'rewrite'       => array( 'slug' => 'location' ),
);
register_taxonomy( 'location', array( 'team-member', 'job' ), $args );

My question: Do I need the 'taxonomies' line below

register_post_type('job', array(
   ....
   'rewrite'     => array('slug' => 'careers'),
   'taxonomies'  => array('location'),
));

Explanation is appreciated. Thanks.

marked as duplicate by Pieter Goosen, TheDeadMedic, birgire, Mayeenul Islam, Howdy_McGee Nov 14 '15 at 3:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

You don't need both, one of them is enough. However you need to do it in a order when thing you are adding support to is already registers.

So in first case you need to define CPT before taxonomy and in second case after.

The third way would be to use register_taxonomy_for_object_type() which let's you do this after both are registered, regardless of order.

Not the answer you're looking for? Browse other questions tagged or ask your own question.