2

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

1 Answer 1

2

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 );
2
  • I think in most scenarios, you dont need "register_taxonomy_for_object_type()" ? Oct 13, 2016 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, 2016 at 0:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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