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)?
Share Improve this question edited Oct 6, 2013 at 11:12 philosophyguy asked Oct 5, 2013 at 15:21 philosophyguyphilosophyguy 1932 silver badges8 bronze badges 2- This very resource: wordpress.stackexchange/… – brasofilo Commented Oct 5, 2013 at 20:03
- Just for fun I did a quick google search »wordpress oop«. I'm not going to post links here, but I can tell you, the first page alone is very resourceful. You might want to start there, besides looking deeper into what WPSE already offers - like brasofilo suggested. Another hint would be looking for those existing wordpress plugin boilerplates/skeletons. – Nicolai Grossherr Commented Oct 6, 2013 at 11:35
1 Answer
Reset to default 0(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' ) );
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744695757a4588479.html
评论列表(0条)