In a plugin, I need to create a custom post type and the associated admin menu modifications with a class rather than procedural code. What is the basic skeleton that I need to build off of in order to do so, and how does that class get hooked into WordPress (i.e., how do I do the "add_action('init','register_my_custom_post_type'), etc. with a class)?
In a plugin, I need to create a custom post type and the associated admin menu modifications with a class rather than procedural code. What is the basic skeleton that I need to build off of in order to do so, and how does that class get hooked into WordPress (i.e., how do I do the "add_action('init','register_my_custom_post_type'), etc. with a class)?
(i.e., how do I do the
add_action('init','register_my_custom_post_type')
, etc. with a class)?
You pass the callback from inside the class, using $this
:
add_action( 'init', array( $this, 'register_my_custom_post_type' ) );