Since WP 4.4, there is a hook you can use to edit default arguments for registered post types:
register_post_type_args
(view in context on trac)
If you’re wanting to remove the permalink/slug from the edit post/page screens but not remove posts from the admin menu itself, setting public => false
and show_ui => true
should do that.
function remove_from_public( $args, $post_type ) {
$args['public'] = false;
$args['show_ui'] = true;
// some other common uses:
//$args['show_in_rest'] = false;
//$args['rewrite'] = false;
//$args['rest_base'] = false;
return $args;
}
add_filter( 'register_post_type_args', 'remove_from_public', PHP_INT_MAX, 2 );
I use PHP_INT_MAX
just to kick it to the bottom of the hook to overwrite anything that may be getting called there.