In what order are these functions supposed to be called?

 register_taxonomy( $catname, $cpt  );
 register_taxonomy_for_object_type(  $catname, $cpt);                                                 
 register_post_type( $cpt, $args );//without the taxonomies argument

Order really shouldn't really matter but it's good practice to register things in a hierarchical structure.

register_post_type( $cpt, $args );
register_taxonomy( $catname, $cpt );
  • I think in most scenarios, you dont need "register_taxonomy_for_object_type()" ? – Doug Cassidy Oct 13 '16 at 15:44
  • 1
    Correct. register_taxonomy_for_object_type() is useful when you want to add an already registered taxonomy to a custom object type. For example, add the default post category taxonomy to your custom post type: register_taxonomy_for_object_type( 'category', $cpt );. – cowgill Oct 14 '16 at 0:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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