目前没有用于注销post类型的函数,但过程非常简单。
Andrew Nacin在trac上提供了一些代码,found here 并张贴在下面。
if ( ! function_exists( \'unregister_post_type\' ) ) :
function unregister_post_type( $post_type ) {
global $wp_post_types;
if ( isset( $wp_post_types[ $post_type ] ) ) {
unset( $wp_post_types[ $post_type ] );
return true;
}
return false;
}
endif;
注销内置帖子类型将对WordPress产生未知影响,因此请自行承担风险。注销自定义post类型应该是完全安全的,但自然不会对安装进行清理(即,注销post类型并不等同于从数据库中删除数据)。
我可以想象一些可能需要这样做的场景,但更明智的方法(如果可能的话)是,如果不需要,首先不注册post类型。