我希望我的插件在激活时自动创建自定义帖子类型。
这是我的代码
register_activation_hook(__FILE__, 'activate_myplugin');
function activate_myplugin() {
add_action('init', 'create_custom_type_post');
function create_custom_type_post() {
register_post_type('customposttype', array(
'label' => 'my custom type post',
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array(
'slug' => 'mycustomposttype',
'with_front' => false
),
'query_var' => true,
'supports' => array(
'title',
'editor',
'excerpt',
'trackbacks',
'custom-fields',
'revisions',
'thumbnail',
'author',
'page-attributes'
)
)
);
}
Run Code Online (Sandbox Code Playgroud)
}
以及停用时如何将其删除?