What hook should you call register_post_type() on?

If you call register_post_type() too early in the WordPress firing sequence you’ll run into fatal PHP errors due to certain conditions not being met in the environment. For instance call register_post_type() without any action trigger will usually lead to failure, either a fatal PHP error or simply failure to register the CPT.

Usually the “init” action hook is recommended for CPT (Custom Post Type) registration in WordPress.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *