How to dynamically register custom post type
That’s not how post type and taxonomy registration work, they are already dynamic. You must call register_post_type on every request, no exceptions, and never later than the init hook. If you do not do this, then the CPT doesn’t exist. register_post_type and register_taxonomy store their data in PHP variables, and do not save that data … Read more